Mantasha Asg 3
Mantasha Asg 3
this.name=name;
this.price=price;
this.quantity=quantity;
this.quantity=quantity;
}
return quantity;
return price*quantity;
double total=calculatetotalprice();
return total-(total*discount/100);
}
@Override
public String toString() {
return "Item: " + name + ", Price: " + price + ", Quantity: " + quantity;
item1 = null;
item2 = null;
if (itemNumber == 1) {
item1 = item;
} else if (itemNumber == 2) {
item2 = item;
}
}
if (item1 != null) {
System.out.println(item1);
totalPrice += item1.calculatetotalprice();
if (item2 != null) {
System.out.println(item2);
totalPrice += item2.calculatetotalprice();}
cart.addItem(item1, 1);
cart.addItem(item2, 2);
cart.displayCart();
public Main() {
}
}