Teil 1 / Aufgabe 4

This commit is contained in:
Sebastian Brosch 2024-05-21 14:49:18 +02:00
parent 949ad201d7
commit 430268ed97
2 changed files with 46 additions and 0 deletions

View 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();
}
}

View 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());
}
}