diff --git a/u10/.classpath b/u10/.classpath new file mode 100644 index 0000000..fb50116 --- /dev/null +++ b/u10/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/u10/.gitignore b/u10/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/u10/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/u10/.project b/u10/.project new file mode 100644 index 0000000..75f4942 --- /dev/null +++ b/u10/.project @@ -0,0 +1,17 @@ + + + u10 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/u10/src/de/hsh/fakturierung/Main.java b/u10/src/de/hsh/fakturierung/Main.java new file mode 100644 index 0000000..5fd8ead --- /dev/null +++ b/u10/src/de/hsh/fakturierung/Main.java @@ -0,0 +1,19 @@ +package de.hsh.fakturierung; + +import de.hsh.fakturierung.rechnung.Rechnung; + +public class Main { + + public static void main(String[] args) { + Rechnung r = new Rechnung(123); + + r.addPos(1, 2.34); + r.addPos(420, 13.37); + r.addPos(42, 3.14); + + System.out.println(r.getPreis(0)); + System.out.println(r.getArtikelnummer(1)); + System.out.println(r.getPreis(2)); + } + +} diff --git a/u10/src/de/hsh/fakturierung/rechnung/Rechnung.java b/u10/src/de/hsh/fakturierung/rechnung/Rechnung.java new file mode 100644 index 0000000..48ebd6b --- /dev/null +++ b/u10/src/de/hsh/fakturierung/rechnung/Rechnung.java @@ -0,0 +1,25 @@ +package de.hsh.fakturierung.rechnung; + +import java.util.ArrayList; + +public class Rechnung { + private int nummer; + private ArrayList positionen; + + public Rechnung(int nummmer) { + this.nummer = nummer; + this.positionen = new ArrayList(); + } + + public void addPos(int artikelnummer, double preis) { + this.positionen.add(new Rechnungsposition(artikelnummer, preis)); + } + + public int getArtikelnummer(int pos) { + return this.positionen.get(pos).getArtikelnummer(); + } + + public double getPreis(int pos) { + return this.positionen.get(pos).getPreis(); + } +} diff --git a/u10/src/de/hsh/fakturierung/rechnung/Rechnungsposition.java b/u10/src/de/hsh/fakturierung/rechnung/Rechnungsposition.java new file mode 100644 index 0000000..d664b52 --- /dev/null +++ b/u10/src/de/hsh/fakturierung/rechnung/Rechnungsposition.java @@ -0,0 +1,18 @@ +package de.hsh.fakturierung.rechnung; + +public class Rechnungsposition { + private int artikelnummer; + private double preis; + Rechnungsposition(int artikelnummer, double preis){ + this.artikelnummer= artikelnummer; + this.preis= preis; + } + + double getPreis() { + return this.preis; + } + + int getArtikelnummer() { + return this.artikelnummer; + } +}