I am trying to apply discount at purchasing products as a menu but output is always 0 at selling price.
import java.util.List;
public class MenuProduct extends Product {
private double totalCE=0;
private double totalSP=0;
public MenuProduct(String name, List<Product> list){
super(name);
for (int i=0; i<list.size(); i++){
if (list.get(i) instanceof MainDish){
totalSP+= (list.get(i).getSellingPrice()*(90/100));
}
else if (list.get(i) instanceof Dessert){
totalSP+= (list.get(i).getSellingPrice()*(80/100));
}
else if (list.get(i) instanceof Beverage){
totalSP+= (list.get(i).getSellingPrice()*(50/100));
}
totalCE+= list.get(i).calculateExpense();
}
}
public double calculateExpense() {
return totalCE;
}
public double getSellingPrice(){
return totalSP;
}
}