Commit 8a30a4b9 authored by 9731050's avatar 9731050

2th

parent d520b22e
Pipeline #407 canceled with stages
...@@ -4,7 +4,7 @@ public class Order { ...@@ -4,7 +4,7 @@ public class Order {
private int id; private int id;
private Customer customer; private Customer customer;
private Food[] foods; private Food[] foods;
private int price; private double price;
public Order(int id, Customer customer, Food[] foods) { public Order(int id, Customer customer, Food[] foods) {
this.id = id; this.id = id;
...@@ -13,10 +13,8 @@ public class Order { ...@@ -13,10 +13,8 @@ public class Order {
for (Food food : foods) { for (Food food : foods) {
price += food.getPrice(); price += food.getPrice();
System.out.println("price="+price);
} }
price *= 1.4; price *= 1.4;
System.out.println("price2="+price);
customer.setOrder(this); customer.setOrder(this);
} }
...@@ -24,7 +22,7 @@ public class Order { ...@@ -24,7 +22,7 @@ public class Order {
return foods; return foods;
} }
public int getPrice() { public double getPrice() {
return price; return price;
} }
...@@ -35,8 +33,12 @@ public class Order { ...@@ -35,8 +33,12 @@ public class Order {
} }
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
temp[foods.length + i] = food; temp[foods.length + i] = food;
// System.out.println("s="+price);
// System.out.println("f="+getPrice());
price=price+(temp[foods.length+i].getPrice())*1.4;
} }
foods = temp; foods = temp;
temp = null; temp = null;
} }
......
...@@ -82,8 +82,9 @@ public class Restaurant { ...@@ -82,8 +82,9 @@ public class Restaurant {
} }
public void acceptPayment(Customer customer) { public void acceptPayment(Customer customer) {
int menuCost = customer.getOrder().getPrice(); double menuCost = customer.getOrder().getPrice();
currentCustomers.remove(customer); currentCustomers.remove(customer);
fund += menuCost * 0.9; fund += menuCost * 0.9;
totalNumOfFood += customer.getOrder().getFoods().length; totalNumOfFood += customer.getOrder().getFoods().length;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment