summaryrefslogtreecommitdiffstats
path: root/src/de/fhswf/in/inf/java1/aufgabe5
diff options
context:
space:
mode:
authorStefan Suhren <suhren.stefan@fh-swf.de>2014-12-07 19:15:58 +0100
committerStefan Suhren <suhren.stefan@fh-swf.de>2014-12-07 19:18:03 +0100
commit9acea903216dbe371dd7b41cbf23b46a5732bcb4 (patch)
tree5a61491ad22e470db8151d2e07f163b011c72d6e /src/de/fhswf/in/inf/java1/aufgabe5
parent8a53a8fca255e4a84ca0e35dac925a223738b98a (diff)
downloadJava1-9acea903216dbe371dd7b41cbf23b46a5732bcb4.tar.gz
Java1-9acea903216dbe371dd7b41cbf23b46a5732bcb4.zip
Refactored the packagenames fo better sorting
Diffstat (limited to 'src/de/fhswf/in/inf/java1/aufgabe5')
-rw-r--r--src/de/fhswf/in/inf/java1/aufgabe5/Bank.java54
-rw-r--r--src/de/fhswf/in/inf/java1/aufgabe5/Konto.java119
-rw-r--r--src/de/fhswf/in/inf/java1/aufgabe5/Person.java86
-rw-r--r--src/de/fhswf/in/inf/java1/aufgabe5/Student.java28
4 files changed, 0 insertions, 287 deletions
diff --git a/src/de/fhswf/in/inf/java1/aufgabe5/Bank.java b/src/de/fhswf/in/inf/java1/aufgabe5/Bank.java
deleted file mode 100644
index 22cb577..0000000
--- a/src/de/fhswf/in/inf/java1/aufgabe5/Bank.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- *
- */
-package de.fhswf.in.inf.java1.aufgabe5;
-
-import java.math.BigDecimal;
-
-/**
- * Package for main function.
- *
- * @author $Author: $
- * @version $Revision: $, $Date: $ UTC
- */
-public final class Bank
-{
-
- /**
- * Prevents instantiation of the unity class Bank.
- *
- */
- private Bank()
- {
-
- }
-
- /**
- * Main function for testing the Bank system.
- *
- * @param args
- * Shell arguments
- */
- public static void main(String[] args)
- {
- Person dieter = new Person("Dieter", "Hallowegers");
-
- Konto giro = new Konto(dieter, new BigDecimal(100));
-
- try
- {
- giro.einzahlen(new BigDecimal(100));
- giro.abheben(new BigDecimal(200));
-
- System.out.println(giro.getKontostand());
-
- giro.abheben(new BigDecimal(1));
- }
- catch (IllegalArgumentException e)
- {
- System.out.println(e);
- }
-
- }
-
-}
diff --git a/src/de/fhswf/in/inf/java1/aufgabe5/Konto.java b/src/de/fhswf/in/inf/java1/aufgabe5/Konto.java
deleted file mode 100644
index faac8f6..0000000
--- a/src/de/fhswf/in/inf/java1/aufgabe5/Konto.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- *
- */
-package de.fhswf.in.inf.java1.aufgabe5;
-
-import java.math.BigDecimal;
-
-/**
- * An implementation of the Konto class which represents a bank account.
- *
- * @author $Author: $
- * @version $Revision: $, $Date: $ UTC
- */
-public class Konto
-{
-
- private BigDecimal guthaben;
-
- private BigDecimal dispo;
-
- private Person besitzer;
-
- /**
- * Creates an account with an owner, a dispo and an initial balance.
- *
- * @param besitzer
- * Owner of the account
- * @param dispo
- * Dispo of the account
- */
- public Konto(Person besitzer, BigDecimal dispo)
- {
-
- if (besitzer == null)
- {
- throw new IllegalArgumentException("Besitzer can't be null");
- }
- if (dispo == null)
- {
- throw new IllegalArgumentException("Dispo can't be null");
- }
- if (dispo.compareTo(BigDecimal.ZERO) < 0)
- {
- throw new IllegalArgumentException("Dispo can't be negative");
- }
-
- this.besitzer = besitzer;
- this.dispo = dispo;
- this.guthaben = new BigDecimal(0);
-
- this.besitzer.addKonto(this);
-
- }
-
- /**
- * Function for withdrawing money from the account.
- *
- * @param betrag
- * Amount of cash to be withdrawn
- */
- public void abheben(BigDecimal betrag)
- {
- if (betrag == null)
- {
- throw new IllegalArgumentException("Betrag can't be null");
- }
- if (betrag.compareTo(BigDecimal.ZERO) < 0)
- {
- throw new IllegalArgumentException("Betrag can't be negative");
- }
- if (guthaben.add(dispo).compareTo(betrag) < 0)
- {
- throw new IllegalArgumentException("Betrag surpasses dispo limit");
- }
-
- guthaben = guthaben.subtract(betrag);
- }
-
- /**
- * Function to deposit money into the account.
- *
- * @param betrag
- * Amount of cash to be disposed
- */
- public void einzahlen(BigDecimal betrag)
- {
- if (betrag == null)
- {
- throw new IllegalArgumentException("Betrag can't be null");
- }
- if (betrag.compareTo(BigDecimal.ZERO) < 0)
- {
- throw new IllegalArgumentException("Betrag can't be negative");
- }
-
- guthaben = guthaben.add(betrag);
- }
-
- /**
- * Returns the actual balance.
- *
- * @return Returns the actual balance.
- */
- public BigDecimal getKontostand()
- {
- return guthaben;
- }
-
- /**
- * Just to get the owners name.
- *
- * @return Returns the owners name.
- */
- public Person getBesitzer()
- {
- return besitzer;
- }
-
-}
diff --git a/src/de/fhswf/in/inf/java1/aufgabe5/Person.java b/src/de/fhswf/in/inf/java1/aufgabe5/Person.java
deleted file mode 100644
index 15de304..0000000
--- a/src/de/fhswf/in/inf/java1/aufgabe5/Person.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- *
- */
-package de.fhswf.in.inf.java1.aufgabe5;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A person which can own an account.
- *
- * @author $Author: $
- * @version $Revision: $, $Date: $ UTC
- */
-public class Person
-{
- private String vorname;
-
- private String nachname;
-
- private List<Konto> kontenliste = new ArrayList<>();
-
- /**
- * Creates a person with first and last name.
- *
- * @param vorname
- * First name of the person
- * @param nachname
- * Last name of the person
- */
- public Person(String vorname, String nachname)
- {
- if (vorname == null)
- {
- throw new IllegalArgumentException("Vorname can't be null");
- }
- if (nachname == null)
- {
- throw new IllegalArgumentException("Nachname can't be null");
- }
- if (vorname.isEmpty())
- {
- throw new IllegalArgumentException("Vorname can't be empty");
- }
- if (nachname.isEmpty())
- {
- throw new IllegalArgumentException("Nachname can't be empty");
- }
- this.vorname = vorname;
- this.nachname = nachname;
- }
-
- /**
- * Just for getting the persons name.
- *
- * @return Returns the full name of the person
- */
- @Override
- public String toString()
- {
- return vorname + " " + nachname;
- }
-
- /**
- * For adding the back reference to the Konto.
- *
- * @param konto
- * Konto that will be added to the person.
- */
- public void addKonto(Konto konto)
- {
- if (konto == null)
- {
- throw new IllegalArgumentException("Konto can't be empty");
- }
- if (konto.getBesitzer() != this)
- {
- throw new IllegalArgumentException("Person must be owner of Konto");
- }
- if (!kontenliste.contains(konto))
- {
- kontenliste.add(konto);
- }
- }
-
-}
diff --git a/src/de/fhswf/in/inf/java1/aufgabe5/Student.java b/src/de/fhswf/in/inf/java1/aufgabe5/Student.java
deleted file mode 100644
index 769c91a..0000000
--- a/src/de/fhswf/in/inf/java1/aufgabe5/Student.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- *
- */
-package de.fhswf.in.inf.java1.aufgabe5;
-
-/**
- * Extends Person and represents a student.
- *
- * @author $Author: $
- * @version $Revision: $, $Date: $ UTC
- */
-public class Student extends Person
-{
-
- /**
- * Simply calls the super constructor to initialize person.
- *
- * @param vorname
- * First name of the student
- * @param nachname
- * Last name of the student
- */
- public Student(String vorname, String nachname)
- {
- super(vorname, nachname);
- }
-
-}