0
/ 1.0
For this question you will be using FoodItem
objects and one GroceryBag
object.
public class FoodItem { private int price; private...
For this question you will be using FoodItem
objects and one GroceryBag
object.
public class FoodItem
{
private int price;
private boolean onSale;
public FoodItem(int p, boolean s)
{
this.price = p;
this.onSale = s;
}
public int getPrice()
{
return price;
}
public boolean isOnSale()
{
return onSale;
}
}
This time the FoodItem
class has changed a bit. Now, price will only ever be an integer, and there is a boolean value onSale
to track if an item is on sale.
The method calculateSalePrice()
should calculate the total price of only the items that are on sale. Complete the loop body so that it performs this task correctly.
Your feedback will appear here when you check your answer.