a
This commit is contained in:
4
Anwendungsentwicklung/src/P2/A.java
Normal file
4
Anwendungsentwicklung/src/P2/A.java
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package P2;
|
||||||
|
|
||||||
|
public class A {
|
||||||
|
}
|
||||||
4
Anwendungsentwicklung/src/P2/B.java
Normal file
4
Anwendungsentwicklung/src/P2/B.java
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package P2;
|
||||||
|
|
||||||
|
public class B extends A{
|
||||||
|
}
|
||||||
9
Anwendungsentwicklung/src/P2/Brot.java
Normal file
9
Anwendungsentwicklung/src/P2/Brot.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package P2;
|
||||||
|
|
||||||
|
public class Brot extends Nahrungsmittel{
|
||||||
|
|
||||||
|
public Brot(){
|
||||||
|
super.setName("Brot");
|
||||||
|
super.setPreis(1f);
|
||||||
|
}
|
||||||
|
}
|
||||||
4
Anwendungsentwicklung/src/P2/C.java
Normal file
4
Anwendungsentwicklung/src/P2/C.java
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package P2;
|
||||||
|
|
||||||
|
public class C extends A{
|
||||||
|
}
|
||||||
4
Anwendungsentwicklung/src/P2/D.java
Normal file
4
Anwendungsentwicklung/src/P2/D.java
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package P2;
|
||||||
|
|
||||||
|
public class D extends A{
|
||||||
|
}
|
||||||
4
Anwendungsentwicklung/src/P2/E.java
Normal file
4
Anwendungsentwicklung/src/P2/E.java
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package P2;
|
||||||
|
|
||||||
|
public class E {
|
||||||
|
}
|
||||||
20
Anwendungsentwicklung/src/P2/Einkaufswagen.java
Normal file
20
Anwendungsentwicklung/src/P2/Einkaufswagen.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package P2;
|
||||||
|
|
||||||
|
public class Einkaufswagen<T> {
|
||||||
|
Nahrungsmittel[] produkte = new Nahrungsmittel[10];
|
||||||
|
int amount = 0;
|
||||||
|
|
||||||
|
void hinzufuegen(Nahrungsmittel produkt){
|
||||||
|
if (amount < 9){
|
||||||
|
produkte[amount++] = produkt;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("voller Lachs");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void ausgeben(){
|
||||||
|
for(int i = 0; i<amount;i++){
|
||||||
|
System.out.println(produkte[i].getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
4
Anwendungsentwicklung/src/P2/F.java
Normal file
4
Anwendungsentwicklung/src/P2/F.java
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package P2;
|
||||||
|
|
||||||
|
public class F {
|
||||||
|
}
|
||||||
5
Anwendungsentwicklung/src/P2/MyGenericClass.java
Normal file
5
Anwendungsentwicklung/src/P2/MyGenericClass.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package P2;
|
||||||
|
|
||||||
|
public class MyGenericClass<T> {
|
||||||
|
// Inhalt der Klasse ist nicht wichtig
|
||||||
|
}
|
||||||
24
Anwendungsentwicklung/src/P2/Nahrungsmittel.java
Normal file
24
Anwendungsentwicklung/src/P2/Nahrungsmittel.java
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package P2;
|
||||||
|
|
||||||
|
public abstract class Nahrungsmittel {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private float preis;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getPreis() {
|
||||||
|
return preis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPreis(float preis) {
|
||||||
|
this.preis = preis;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
11
Anwendungsentwicklung/src/P2/Test.java
Normal file
11
Anwendungsentwicklung/src/P2/Test.java
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package P2;
|
||||||
|
|
||||||
|
public class Test {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
var test= new MyGenericClass<A>();
|
||||||
|
testCreate(test);
|
||||||
|
}
|
||||||
|
static void testCreate(MyGenericClass<? super C> c ){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
42
Anwendungsentwicklung/src/P2/Test2.java
Normal file
42
Anwendungsentwicklung/src/P2/Test2.java
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package P2;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Test2 <T,X>{
|
||||||
|
public static void main(String[] args) {
|
||||||
|
boolean end = false;
|
||||||
|
|
||||||
|
|
||||||
|
Scanner sc = new Scanner(System.in);
|
||||||
|
|
||||||
|
Einkaufswagen<? extends Nahrungsmittel> einkaufswagen = new Einkaufswagen();
|
||||||
|
|
||||||
|
while (!end) {
|
||||||
|
System.out.println("1: Brot");
|
||||||
|
System.out.println("2: Wurst");
|
||||||
|
System.out.println("3: Ausgeben");
|
||||||
|
System.out.println("4: handelsbuch(produkt, menge)");
|
||||||
|
System.out.println("5: Ende");
|
||||||
|
System.out.println("");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
switch (sc.nextInt()) {
|
||||||
|
case 1:
|
||||||
|
einkaufswagen.hinzufuegen(new Brot());
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
einkaufswagen.hinzufuegen(new Wurst());
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
einkaufswagen.ausgeben();
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
end = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
8
Anwendungsentwicklung/src/P2/Wurst.java
Normal file
8
Anwendungsentwicklung/src/P2/Wurst.java
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package P2;
|
||||||
|
|
||||||
|
public class Wurst extends Nahrungsmittel{
|
||||||
|
public Wurst(){
|
||||||
|
super.setName("Wurst");
|
||||||
|
super.setPreis(1.1f);
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
out/production/Anwendungsentwicklung/P2/A.class
Normal file
BIN
out/production/Anwendungsentwicklung/P2/A.class
Normal file
Binary file not shown.
BIN
out/production/Anwendungsentwicklung/P2/B.class
Normal file
BIN
out/production/Anwendungsentwicklung/P2/B.class
Normal file
Binary file not shown.
BIN
out/production/Anwendungsentwicklung/P2/Brot.class
Normal file
BIN
out/production/Anwendungsentwicklung/P2/Brot.class
Normal file
Binary file not shown.
BIN
out/production/Anwendungsentwicklung/P2/C.class
Normal file
BIN
out/production/Anwendungsentwicklung/P2/C.class
Normal file
Binary file not shown.
BIN
out/production/Anwendungsentwicklung/P2/D.class
Normal file
BIN
out/production/Anwendungsentwicklung/P2/D.class
Normal file
Binary file not shown.
BIN
out/production/Anwendungsentwicklung/P2/E.class
Normal file
BIN
out/production/Anwendungsentwicklung/P2/E.class
Normal file
Binary file not shown.
BIN
out/production/Anwendungsentwicklung/P2/Einkaufswagen.class
Normal file
BIN
out/production/Anwendungsentwicklung/P2/Einkaufswagen.class
Normal file
Binary file not shown.
BIN
out/production/Anwendungsentwicklung/P2/F.class
Normal file
BIN
out/production/Anwendungsentwicklung/P2/F.class
Normal file
Binary file not shown.
BIN
out/production/Anwendungsentwicklung/P2/MyGenericClass.class
Normal file
BIN
out/production/Anwendungsentwicklung/P2/MyGenericClass.class
Normal file
Binary file not shown.
BIN
out/production/Anwendungsentwicklung/P2/Nahrungsmittel.class
Normal file
BIN
out/production/Anwendungsentwicklung/P2/Nahrungsmittel.class
Normal file
Binary file not shown.
BIN
out/production/Anwendungsentwicklung/P2/Test.class
Normal file
BIN
out/production/Anwendungsentwicklung/P2/Test.class
Normal file
Binary file not shown.
BIN
out/production/Anwendungsentwicklung/P2/Test2.class
Normal file
BIN
out/production/Anwendungsentwicklung/P2/Test2.class
Normal file
Binary file not shown.
BIN
out/production/Anwendungsentwicklung/P2/Wurst.class
Normal file
BIN
out/production/Anwendungsentwicklung/P2/Wurst.class
Normal file
Binary file not shown.
Reference in New Issue
Block a user