From cbfcc3df88e229a81da783e258a0b8860404fe1a Mon Sep 17 00:00:00 2001 From: Stefan Suhren Date: Wed, 29 Oct 2014 13:21:44 +0100 Subject: Assignment No.2 after correction --- src/de/fhswf/in/inf/java1/aufgabe5/Konto.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/de/fhswf/in/inf/java1/aufgabe5/Konto.java') diff --git a/src/de/fhswf/in/inf/java1/aufgabe5/Konto.java b/src/de/fhswf/in/inf/java1/aufgabe5/Konto.java index a2af51c..faac8f6 100644 --- a/src/de/fhswf/in/inf/java1/aufgabe5/Konto.java +++ b/src/de/fhswf/in/inf/java1/aufgabe5/Konto.java @@ -27,10 +27,8 @@ public class Konto * Owner of the account * @param dispo * Dispo of the account - * @param guthaben - * Initial balance of the account */ - public Konto(Person besitzer, BigDecimal dispo, BigDecimal guthaben) + public Konto(Person besitzer, BigDecimal dispo) { if (besitzer == null) @@ -41,14 +39,16 @@ public class Konto { throw new IllegalArgumentException("Dispo can't be null"); } - if (guthaben == null) + if (dispo.compareTo(BigDecimal.ZERO) < 0) { - throw new IllegalArgumentException("Guthaben can't be null"); + throw new IllegalArgumentException("Dispo can't be negative"); } this.besitzer = besitzer; this.dispo = dispo; - this.guthaben = guthaben; + this.guthaben = new BigDecimal(0); + + this.besitzer.addKonto(this); } @@ -111,9 +111,9 @@ public class Konto * * @return Returns the owners name. */ - public String getBesitzer() + public Person getBesitzer() { - return besitzer.getName(); + return besitzer; } } -- cgit v1.2.3-70-g09d2