Browse Source

Commit_32 setBalanceView implementiert und getestet. Balance reagiert beim Eingeben der Ausgaben

Mohamed
Adah Boukhari 5 years ago
parent
commit
8304339da4
  1. BIN
      Budget Projekt/Image/exit.png
  2. BIN
      Budget Projekt/Image/leeren.png
  3. BIN
      Budget Projekt/bin/MeinBudgetView/MeinGui.class
  4. BIN
      Budget Projekt/bin/MeinBudgetView/MyTest.class
  5. BIN
      Budget Projekt/bin/exit.png
  6. BIN
      Budget Projekt/bin/leeren.png
  7. 20
      Budget Projekt/src/MeinBudgetView/MeinGui.java
  8. 32
      Budget Projekt/src/MeinBudgetView/MyTest.java

BIN
Budget Projekt/Image/exit.png

After

Width: 48  |  Height: 48  |  Size: 4.4 KiB

BIN
Budget Projekt/Image/leeren.png

After

Width: 48  |  Height: 48  |  Size: 1.8 KiB

BIN
Budget Projekt/bin/MeinBudgetView/MeinGui.class

BIN
Budget Projekt/bin/MeinBudgetView/MyTest.class

BIN
Budget Projekt/bin/exit.png

After

Width: 48  |  Height: 48  |  Size: 4.4 KiB

BIN
Budget Projekt/bin/leeren.png

After

Width: 48  |  Height: 48  |  Size: 1.8 KiB

20
Budget Projekt/src/MeinBudgetView/MeinGui.java

@ -250,14 +250,15 @@ public class MeinGui extends JFrame implements ActionListener {
} }
if (ae.getSource() == this.berechne && (text1 != null && text2 != null)) { if (ae.getSource() == this.berechne && (text1 != null && text2 != null)) {
expenses = budget - Double.parseDouble(text2.getText());
expensesDisplay.setText(setExpensesView());
balance = Double.parseDouble(text1.getText()) - Double.parseDouble(text2.getText());
DefaultTableModel tab = (DefaultTableModel) myTable.getModel();
tab.addRow(new Object[] { (textExpensesName.getText()), Double.parseDouble(text2.getText()) });
balance -= Double.parseDouble(text2.getText());
expenses += Double.parseDouble(text2.getText());
balanceDisplay.setText(setBalanceView()); balanceDisplay.setText(setBalanceView());
} }
DefaultTableModel tab = (DefaultTableModel)myTable.getModel();
tab.addRow(new Object [] {(textExpensesName.getText()) , Double.parseDouble(text2.getText())});
} }
@ -272,7 +273,7 @@ public class MeinGui extends JFrame implements ActionListener {
expensesDisplay.setText(null); expensesDisplay.setText(null);
balanceDisplay.setText(null); balanceDisplay.setText(null);
textExpensesName.setText(null); textExpensesName.setText(null);
((DefaultTableModel)myTable.getModel()).setRowCount(0);
((DefaultTableModel) myTable.getModel()).setRowCount(0);
} }
public static String setBudgetView() { public static String setBudgetView() {
@ -280,13 +281,8 @@ public class MeinGui extends JFrame implements ActionListener {
return result; return result;
} }
public static String setExpensesView() {
String result = expenses - budget + " €";
return result;
}
public static String setBalanceView() { public static String setBalanceView() {
String result = balance + " €";
String result = budget - expenses + " €";
return result; return result;
} }

32
Budget Projekt/src/MeinBudgetView/MyTest.java

@ -8,31 +8,27 @@ class MyTest {
@Test @Test
public void testSetBudgetView() { public void testSetBudgetView() {
assertEquals(MeinGui.budget + " €", MeinGui.setBudgetView());
assertNotEquals(MeinGui.budget + " ", MeinGui.setBudgetView());
assertNotEquals(MeinGui.budget + "€ ", MeinGui.setBudgetView());
assertNotEquals(MeinGui.budget + " € ", MeinGui.setBudgetView());
assertNotEquals(MeinGui.budget + " ", MeinGui.setBudgetView());
}
MeinGui.budget = 2000.;
@Test
public void testSetExpensesView() {
assertEquals(MeinGui.expenses - MeinGui.budget + " €", MeinGui.setExpensesView());
assertNotEquals(MeinGui.expenses - MeinGui.budget, MeinGui.setExpensesView());
assertNotEquals(MeinGui.expenses - MeinGui.budget + "€ " , MeinGui.setExpensesView());
assertNotEquals(MeinGui.expenses - MeinGui.budget + " € " , MeinGui.setExpensesView());
assertNotEquals(MeinGui.expenses - MeinGui.budget + "", MeinGui.setExpensesView());
assertEquals(2000.0 + " €", MeinGui.setBudgetView());
assertNotEquals(2000 + " €", MeinGui.setBudgetView());
assertNotEquals(2000.0 + "€ ", MeinGui.setBudgetView());
assertNotEquals(2000 + " €", MeinGui.setBudgetView());
assertNotEquals(2000.0 + "€", MeinGui.setBudgetView());
} }
@Test @Test
public void testSetBalanceView() { public void testSetBalanceView() {
assertEquals(MeinGui.balance + " €", MeinGui.setExpensesView());
assertNotEquals(MeinGui.balance, MeinGui.setExpensesView());
assertNotEquals(MeinGui.balance + "€ " , MeinGui.setExpensesView());
assertNotEquals(MeinGui.balance+ " € " , MeinGui.setExpensesView());
assertNotEquals(MeinGui.balance*2 + " € ", MeinGui.setExpensesView());
MeinGui.budget = 2000.;
MeinGui.expenses = 405.;
assertEquals(1595.0 + " €", MeinGui.setBalanceView());
assertNotEquals(1595 + " €", MeinGui.setBalanceView());
assertNotEquals(1595 + "€ ", MeinGui.setBalanceView());
assertNotEquals(1595 + "€", MeinGui.setBalanceView());
assertNotEquals(null, MeinGui.setBalanceView());
} }

Loading…
Cancel
Save