Teil 1 / Aufgabe 4
This commit is contained in:
parent
949ad201d7
commit
430268ed97
16
T01/Aufgabe04/Aufgabe04.java
Normal file
16
T01/Aufgabe04/Aufgabe04.java
Normal file
@ -0,0 +1,16 @@
|
||||
package T01.Aufgabe04;
|
||||
|
||||
/**
|
||||
* Teil 1 / Aufgabe 4
|
||||
*
|
||||
* @author Sebastian Brosch
|
||||
*/
|
||||
class Aufgabe04 {
|
||||
public static void main(String[] args) {
|
||||
Produkt mehl = new Produkt(1, "Mehl", 2.5, Regalnummer.Regal01);
|
||||
mehl.print();
|
||||
|
||||
Produkt salz = new Produkt(2, "Salz", 3.5, Regalnummer.Regal02);
|
||||
salz.print();
|
||||
}
|
||||
}
|
30
T01/Aufgabe04/Produkt.java
Normal file
30
T01/Aufgabe04/Produkt.java
Normal file
@ -0,0 +1,30 @@
|
||||
package T01.Aufgabe04;
|
||||
|
||||
/**
|
||||
* List with all available shelf numbers.
|
||||
*/
|
||||
enum Regalnummer {
|
||||
Regal01, Regal02, Regal03, Regal04, Regel05
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to represent a Produkt.
|
||||
*/
|
||||
public class Produkt {
|
||||
int id;
|
||||
String name;
|
||||
double nettopreis;
|
||||
Regalnummer regal;
|
||||
|
||||
Produkt(int id, String name, double nettopreis, Regalnummer regal) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.nettopreis = nettopreis;
|
||||
this.regal = regal;
|
||||
}
|
||||
|
||||
void print() {
|
||||
System.out.printf("%d - %s: %.2f (%s)\n", this.id, this.name, this.nettopreis,
|
||||
this.regal.toString());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user