0% found this document useful (0 votes)
3 views2 pages

#1 2010

Uploaded by

Rahul Pardeshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

#1 2010

Uploaded by

Rahul Pardeshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

public int getTotalBoxes() {

int totalBoxes = 0;
for (int i = 0; i < orders.size(); i++) {
totalBoxes += orders.get(i).getNumBoxes();
}
return totalBoxes;
}

public int removeVariety(String cookieVar) {


int boxesRemoved = 0;
List<CookieOrder> newOrders = new ArrayList<CookieOrder>();
for (int i = 0; i < orders.size(); i++) {
if (orders.get(i).getVariety().equals(cookieVar)) {
boxesRemoved += orders.get(i).getNumBoxes();
}
else {
newOrders.add(orders.get(i));
}
}
orders = newOrders;
return boxesRemoved;
}

public boolean equals(CookieOrder x) {


if (x == null || this == null) {return false;}
System.out.println(x);
if (x.getVariety().equals(this.getVariety())) {return true;}
}
public int removeVariety(String cookieVar) {
int boxesRemoved = 0;
List<CookieOrder> newOrders = new ArrayList<CookieOrder>();
for (int i = 0; i < orders.size(); i++) {
if (orders.get(i).getVariety().equals(cookieVar)) {
boxesRemoved += orders.get(i).getNumBoxes();
orders.remove(orders.get(i));
}
}
orders = newOrders;
return boxesRemoved;
}

public int removeVariety(String cookieVar) {


int x = 0;
int boxesRemoved = 0;
List<CookieOrder> newOrders = new ArrayList<CookieOrder>();
for (int i = 0; i < orders.size(); i++) {
if (orders.get(i - x).getVariety().equals(cookieVar)) {
boxesRemoved += orders.get(i - x).getNumBoxes();
orders.remove(i - x);
x++;
}
}
orders = newOrders;
return boxesRemoved;
}
0 1 2 3 4 x = 0
x = 0, 0 2 3 4
x = 1, 0 2 3 4
x = 1,

You might also like