AHHHHHHHHHH COMMITED TO GITHUB INSTEAD OF FORGEJO FOR WEEKS

This commit is contained in:
sageTheDM 2024-12-16 20:32:46 +01:00
parent d6ef44f3d1
commit 0919005cb2
163 changed files with 3875 additions and 47 deletions

View file

@ -0,0 +1,24 @@
import java.util.ArrayList;
public class App {
public static void main(String[] args) throws Exception {
ArrayList<Samsung> devices = new ArrayList<Samsung>();
devices.add(new GalaxyJ3(11.85, "Phone"));
devices.add(new GalaxyS5(12.45, "phone", "sunset-black"));
for (Samsung samsung : devices) {
System.out.println(samsung.preis);
System.out.println(samsung.produktTyp);
if (samsung instanceof GalaxyS5) {
System.out.println(((GalaxyS5) samsung).farbe);
}
System.out.println("Funktionstest");
if (samsung instanceof ITelefon) {
((ITelefon) samsung).powerOn();
((ITelefon) samsung).esKlingelt();
((ITelefon) samsung).anrufen();
}
System.out.println();
}
}
}

View file

@ -0,0 +1,22 @@
public class GalaxyJ3 extends Samsung implements ITelefon {
public GalaxyJ3(double preis, String produktTyp) {
super(preis, produktTyp);
}
@Override
public void powerOn() {
System.out.println("GalaxyJ3 is starting");
}
@Override
public void esKlingelt() {
System.out.println("DING DING DING");
}
@Override
public void anrufen() {
System.out.println("No one will pick up - since you have no signal in the basement");
}
}

View file

@ -0,0 +1,23 @@
public class GalaxyS5 extends Samsung implements ITelefon {
String farbe;
public GalaxyS5(double preis, String produktTyp, String farbe) {
super(preis, produktTyp);
this.farbe = farbe;
}
@Override
public void powerOn() {
System.out.println("GalaxyJ5 is starting");
}
@Override
public void esKlingelt() {
System.out.println("DING DING DING");
}
@Override
public void anrufen() {
System.out.println("No one will pick up - since you have no signal in the basement");
}
}

View file

@ -0,0 +1,7 @@
public interface ITelefon {
public void powerOn();
public void esKlingelt();
public void anrufen();
}

View file

@ -0,0 +1,9 @@
public abstract class Samsung {
double preis;
String produktTyp;
public Samsung(double preis, String produktTyp) {
this.preis = preis;
this.produktTyp = produktTyp;
}
}