Browse Source

Arraylist remove Methode hinzugefügt

Eduard2
eduardD 5 years ago
parent
commit
14d671a2a3
  1. 10
      Budget Projekt/src/MeinBudgetView/Calculations.java
  2. 17
      Budget Projekt/src/MeinBudgetView/MyTest.java

10
Budget Projekt/src/MeinBudgetView/Calculations.java

@ -49,5 +49,15 @@ public class Calculations {
allExpenses.clear(); allExpenses.clear();
} }
public static void removeExpense(int expense) {
for(int i = 0; i < allExpenses.size();i++) {
if(allExpenses.get(i) == expense) {
allExpenses.remove(i);
return;
}
}
}
} }

17
Budget Projekt/src/MeinBudgetView/MyTest.java

@ -70,6 +70,23 @@ class MyTest {
assertThat(expenseReturn, equalTo(expectedResult)); assertThat(expenseReturn, equalTo(expectedResult));
} }
@Test
public void remove_one_expense() {
//arrange
Calculations.clearExpenses();
int expense1 = 500;
int expense2 = 300;
//act
Calculations.addExpense(expense1);
Calculations.addExpense(expense2);
Calculations.removeExpense(expense1);
int expenseReturn = Calculations.getExpenseSum();
//assert
assertThat(expenseReturn, equalTo(expense2));
}
/* /*
@Test @Test
void score_incompleteFrames_sumOfRolls() { void score_incompleteFrames_sumOfRolls() {

Loading…
Cancel
Save