Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ultimos cambios

  • Loading branch information...
commit 3e89b8210c2a54a3976483184479d8b943eaadda 1 parent 457b7a7
@rubensanroman rubensanroman authored
View
BIN  out/production/Expense-report/expenseReport/ExpenseReport.class
Binary file not shown
View
23 src/expenseReport/ExpenseReport.java
@@ -13,30 +13,25 @@
private int totalExpenses = 0;
private String reportOutPut = "";
- public void printReport(ReportPrinter printer) {
+ public void printReport(ReportPrinter printer) {
reportOutPut += "Expenses " + getDate() + "\n";
for (Expense expense : expenses) {
switch (expense.type) {
-
case DINNER:
appendExpense("Dinner",expense.amount);
break;
-
case BREAKFAST:
appendExpense("Breakfast",expense.amount);
break;
-
case CAR_RENTAL:
appendExpense("Car Rental",expense.amount);
break;
-
default:
appendExpense("TILT",0);
break;
-
}
}
@@ -56,17 +51,11 @@ private String getDate() {
return "9/12/2002";
}
- private boolean isMeal(String expense) {
- return (expense == "Dinner" || expense == "Breakfast") ? true : false;
- }
-
- private void appendExpense(String expense, int amount) {
-
- if (isMeal(expense)) mealExpenses += amount;
- reportOutPut += ((expense == "Dinner" && amount > 5000) || (expense == "Breakfast" && amount > 1000)) ? "X" : " ";
- reportOutPut += "\t"+expense+"\t$"+amount/100.0+"\n";
- totalExpenses += amount;
-
+ private void appendExpense(String expenseType, int expenseAmount) {
+ mealExpenses = (expenseType == "Dinner" || expenseType == "Breakfast") ? mealExpenses+expenseAmount : mealExpenses;
+ reportOutPut += ((expenseType == "Dinner" && expenseAmount > 5000) || (expenseType == "Breakfast" && expenseAmount > 1000)) ? "X" : " ";
+ reportOutPut += "\t"+expenseType+"\t$"+expenseAmount/100.0+"\n";
+ totalExpenses += expenseAmount;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.