Skip to content

Commit

Permalink
Update App.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicon193 committed Jun 28, 2020
1 parent 2e4bbca commit 92b004f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public HashMap<Item,Integer> bill(List<String>inputs,List<Item> items){


public StringBuffer detail(HashMap<Item,Integer> bills){
double total =0;
double half_Price =0;
int number =0;
Double total =0.0;
Double half_Price =0.0;
Integer number =0;
boolean half =false;
List<String> cutFood=new ArrayList<>();
List<SalesPromotion> salesPromotions=salesPromotionRepository.findAll();
Expand All @@ -62,7 +62,7 @@ public StringBuffer detail(HashMap<Item,Integer> bills){
while(iterator.hasNext()){
Item item= (Item) iterator.next();
number = bills.get(item);
order.append(item.getName()+" x "+number+" = "+(int)(number*item.getPrice())+" yuan\n");
order.append(item.getName()+" x "+number+" = "+((Double)(number*item.getPrice())).intValue()+" yuan\n");
total+=number*item.getPrice();

if(salesPromotions.get(1).getRelatedItems().contains(item.getId())){
Expand All @@ -86,7 +86,7 @@ public StringBuffer detail(HashMap<Item,Integer> bills){
if(i!=cutFood.size()-1){
order.append(cutFood.get(i)+",");
}else{
order.append(cutFood.get(i)+"),saving "+(int)half_Price+" yuan\n");
order.append(cutFood.get(i)+"),saving "+half_Price.intValue()+" yuan\n");
order.append("-----------------------------------\n");
}
}
Expand All @@ -100,7 +100,7 @@ public StringBuffer detail(HashMap<Item,Integer> bills){
"-----------------------------------\n");
}

order.append("Total:"+(int)total+" yuan\n"+
order.append("Total:"+total.intValue()+" yuan\n"+
"===================================");

return order;
Expand Down

0 comments on commit 92b004f

Please sign in to comment.