-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrder.java
More file actions
27 lines (24 loc) · 704 Bytes
/
Copy pathOrder.java
File metadata and controls
27 lines (24 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.util.ArrayList;
public class Order{
private ArrayList<Pizza> pizzas= new ArrayList<>();
static final double tax= 0.0053;
public void addPizza(Pizza pizza){
pizzas.add(pizza);
}
public double taxValue(){
return tax;
}
public double OrdertotalPrice(){
double sumPrice=0;
for(Pizza pitza: pizzas){
sumPrice=sumPrice + pitza.totalPrice() ;}
return sumPrice+ (sumPrice*tax);
}
public String toString(){
String description= "";
for (Pizza pizza : pizzas) {
description += String.format("%s%n with tax of %g totals to %f\n", pizza.toString(),tax,pizza.totalPrice()+(pizza.totalPrice()*tax));
}
return description ;
}
}