commit 11a6cbcca83a37bce7b6686a65f99d0af930c299 Author: peet Date: Mon Jun 10 00:31:44 2024 +0200 initial commit diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/bin/Main.class b/bin/Main.class new file mode 100644 index 0000000..0733ac4 Binary files /dev/null and b/bin/Main.class differ diff --git a/bin/Spieler/FieldPlayer.class b/bin/Spieler/FieldPlayer.class new file mode 100644 index 0000000..fb0090d Binary files /dev/null and b/bin/Spieler/FieldPlayer.class differ diff --git a/bin/Spieler/Goalkeeper.class b/bin/Spieler/Goalkeeper.class new file mode 100644 index 0000000..0fab918 Binary files /dev/null and b/bin/Spieler/Goalkeeper.class differ diff --git a/bin/Spieler/Mannschaft.class b/bin/Spieler/Mannschaft.class new file mode 100644 index 0000000..8711530 Binary files /dev/null and b/bin/Spieler/Mannschaft.class differ diff --git a/bin/Spieler/Player.class b/bin/Spieler/Player.class new file mode 100644 index 0000000..16e7bf8 Binary files /dev/null and b/bin/Spieler/Player.class differ diff --git a/bin/Spieler/Position.class b/bin/Spieler/Position.class new file mode 100644 index 0000000..bff50a7 Binary files /dev/null and b/bin/Spieler/Position.class differ diff --git a/bin/Spieler/TestPlayer.class b/bin/Spieler/TestPlayer.class new file mode 100644 index 0000000..df3041e Binary files /dev/null and b/bin/Spieler/TestPlayer.class differ diff --git a/bin/Stadion/Empty.class b/bin/Stadion/Empty.class new file mode 100644 index 0000000..bfd6f70 Binary files /dev/null and b/bin/Stadion/Empty.class differ diff --git a/bin/Stadion/Full.class b/bin/Stadion/Full.class new file mode 100644 index 0000000..1669bfb Binary files /dev/null and b/bin/Stadion/Full.class differ diff --git a/bin/Stadion/Stadion.class b/bin/Stadion/Stadion.class new file mode 100644 index 0000000..2814de5 Binary files /dev/null and b/bin/Stadion/Stadion.class differ diff --git a/bin/Stadion/StadionState.class b/bin/Stadion/StadionState.class new file mode 100644 index 0000000..3260177 Binary files /dev/null and b/bin/Stadion/StadionState.class differ diff --git a/bin/Stadion/TestStadion.class b/bin/Stadion/TestStadion.class new file mode 100644 index 0000000..057cad2 Binary files /dev/null and b/bin/Stadion/TestStadion.class differ diff --git a/bin/Trainingsplatz/Belegt.class b/bin/Trainingsplatz/Belegt.class new file mode 100644 index 0000000..52787bc Binary files /dev/null and b/bin/Trainingsplatz/Belegt.class differ diff --git a/bin/Trainingsplatz/Frei.class b/bin/Trainingsplatz/Frei.class new file mode 100644 index 0000000..12ca25e Binary files /dev/null and b/bin/Trainingsplatz/Frei.class differ diff --git a/bin/Trainingsplatz/State.class b/bin/Trainingsplatz/State.class new file mode 100644 index 0000000..a197246 Binary files /dev/null and b/bin/Trainingsplatz/State.class differ diff --git a/bin/Trainingsplatz/Trainingsplatz.class b/bin/Trainingsplatz/Trainingsplatz.class new file mode 100644 index 0000000..01d3f98 Binary files /dev/null and b/bin/Trainingsplatz/Trainingsplatz.class differ diff --git a/bin/Verein/Mannschaft.class b/bin/Verein/Mannschaft.class new file mode 100644 index 0000000..da1d1d4 Binary files /dev/null and b/bin/Verein/Mannschaft.class differ diff --git a/src/Main.java b/src/Main.java new file mode 100644 index 0000000..3e59c38 --- /dev/null +++ b/src/Main.java @@ -0,0 +1,5 @@ +public class Main { + public static void main(String[] args) { + System.out.println("Hello world!"); + } +} \ No newline at end of file diff --git a/src/Spieler/FieldPlayer.java b/src/Spieler/FieldPlayer.java new file mode 100644 index 0000000..458565b --- /dev/null +++ b/src/Spieler/FieldPlayer.java @@ -0,0 +1,57 @@ +package Spieler; + +public class FieldPlayer extends Player { + + private String name; + private int kondition; + private int zweikampf; + private int kopfball; + private int technik; + Position position; + + + public FieldPlayer(String name, Position position, int kondition, int zweikampf, int kopfball, int technik) { + + if ( kondition <= 0 || name == null || position==null || zweikampf<= 0 || kopfball<0 || technik<0 ){ + throw new IllegalArgumentException("Einer der Spielerwerte ist 0 oder negativ oder Name ist leer. Ändere das!"); + } else + + this.name = name; + this.position=position; + this.kondition= kondition; + this.zweikampf=zweikampf; + this.kopfball=kopfball; + this.technik=technik; + } + + public String getName(){ + return name; + } + public Position getPosition(){ + return position; + } + + public int getKondition(){ + return kondition; + } + + public int getZweikampf() { + return zweikampf; + } + public int getKopfball(){ + return kopfball; + } + public int getTechnik(){ + return technik; + } + + public String toString(){ + return name + position + kondition +zweikampf + kopfball + technik; + } + + + + + + +} diff --git a/src/Spieler/Goalkeeper.java b/src/Spieler/Goalkeeper.java new file mode 100644 index 0000000..d7d3459 --- /dev/null +++ b/src/Spieler/Goalkeeper.java @@ -0,0 +1,36 @@ +package Spieler; + +public class Goalkeeper extends Player { + + private String name; + private Position position; + private int reflexe; + private int strafraum; + + public Goalkeeper(String name, Position position, int reflexe, int strafraum) { + this.name = name; + this.reflexe = reflexe; + this.strafraum = strafraum; + + if (position != Position.GOALKEEPER){ + throw new IllegalArgumentException("Ein Torwart braucht die Position Goalkeeper!");} + else + this.position = position; + + } + + public String getName(){ + return name; + } + public Position getPosition(){ + return position; + } + public int getReflexe(){ + return reflexe; + } + public int getStrafraum(){ + return strafraum; + } + + +} diff --git a/src/Spieler/Mannschaft.java b/src/Spieler/Mannschaft.java new file mode 100644 index 0000000..de7aa31 --- /dev/null +++ b/src/Spieler/Mannschaft.java @@ -0,0 +1,8 @@ +package Spieler; +import java.util.ArrayList; +import java.util.List; + + +public class Mannschaft { + +} \ No newline at end of file diff --git a/src/Spieler/Player.java b/src/Spieler/Player.java new file mode 100644 index 0000000..475987d --- /dev/null +++ b/src/Spieler/Player.java @@ -0,0 +1,22 @@ +package Spieler; + +public class Player { + + + //Konstruktor für FieldPlayer + public FieldPlayer createFieldPlayer(String name, Position position, int kondition, int zweikampf, int kopfball, int technik){ + + FieldPlayer fieldplayer = new FieldPlayer(name, position, kondition, zweikampf, kopfball, technik ); + + return fieldplayer; + } + + //Konstruktor für Goalkeeper + public Goalkeeper createGoalkeeper(String name, Position position, int reflexe, int strafraum){ + + Goalkeeper goalkeeper = new Goalkeeper(name, position, reflexe, strafraum); + + return goalkeeper; + } + +} diff --git a/src/Spieler/Position.java b/src/Spieler/Position.java new file mode 100644 index 0000000..2686a61 --- /dev/null +++ b/src/Spieler/Position.java @@ -0,0 +1,9 @@ +package Spieler; + +public enum Position { + + GOALKEEPER, + DEFENDER, + MIDFIELD, + STRIKER +} diff --git a/src/Spieler/TestPlayer.java b/src/Spieler/TestPlayer.java new file mode 100644 index 0000000..ef6b06b --- /dev/null +++ b/src/Spieler/TestPlayer.java @@ -0,0 +1,45 @@ +package Spieler; + +import org.testng.annotations.Test; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertThrows; + +public class TestPlayer { + + @Test + public void createFieldPlayerTest() { + //Instanz von Player erstellen, damit ich createFieldPlayer überhaupt aufrufen kann. + Player player = new Player(); + //Instanz von Fieldplayer erstellen + FieldPlayer fieldPlayer = player.createFieldPlayer("Westermann", Position.DEFENDER, 1,2,3,1); + //Die Attribute von FieldPlayer werden alle einzeln geprüft! + assertEquals("Westermann", fieldPlayer.getName()); + assertEquals(Position.DEFENDER, fieldPlayer.getPosition()); + assertEquals(1, fieldPlayer.getKondition()); + assertEquals(2, fieldPlayer.getZweikampf()); + assertEquals(3, fieldPlayer.getKopfball()); + assertEquals(1, fieldPlayer.getTechnik()); + } + + @Test + public void createGoalkeeperTest() { + //Klassenobjekt um create aufrufen zu können + Player player = new Player(); + + //Testobjekt, das gegen getestet wird. + Goalkeeper goalkeeper = player.createGoalkeeper("Lehmann", Position.GOALKEEPER, 5, 5); + + //Jedes Attribut einzeln testen + assertEquals("Lehmann", goalkeeper.getName()); + assertEquals(Position.GOALKEEPER, goalkeeper.getPosition()); + assertEquals(5, goalkeeper.getReflexe()); + assertEquals(5, goalkeeper.getStrafraum()); + } + + //Testet die Position exception, die im Konstruktor von Goalkeeper ist. + @Test(expectedExceptions = IllegalArgumentException.class) + public void goalkeeperExceptionTest(){ + Player player =new Player(); + Goalkeeper goalkeeper = player.createGoalkeeper("Hanslik",Position.STRIKER,1,1); + } +} diff --git a/src/Stadion/Empty.java b/src/Stadion/Empty.java new file mode 100644 index 0000000..1dcb062 --- /dev/null +++ b/src/Stadion/Empty.java @@ -0,0 +1,16 @@ +package Stadion; + +public class Empty extends StadionState{ + + //Aufruf Konstruktor Mutterklasse per super + Empty (Stadion stadion) { + super (stadion); + } + + + public void ausverkauft(){ + stadion.setState(new Full(stadion)); + }; + + public void leer(){}; +} diff --git a/src/Stadion/Full.java b/src/Stadion/Full.java new file mode 100644 index 0000000..d630ce4 --- /dev/null +++ b/src/Stadion/Full.java @@ -0,0 +1,15 @@ +package Stadion; + +public class Full extends StadionState{ + + //Aufruf Konstruktor Mutterklasse per super + Full(Stadion stadion){ + super(stadion); + } + + @Override + public void ausverkauft(){}; + + @Override + public void leer(){stadion.setState(new Empty(stadion));} +} diff --git a/src/Stadion/Stadion.java b/src/Stadion/Stadion.java new file mode 100644 index 0000000..52b58bc --- /dev/null +++ b/src/Stadion/Stadion.java @@ -0,0 +1,12 @@ +package Stadion; + +public class Stadion { + private StadionState state; + + public Stadion(){ + state = new Empty(this); + } + + public void setState(StadionState state){this.state=state;} + +} diff --git a/src/Stadion/StadionState.java b/src/Stadion/StadionState.java new file mode 100644 index 0000000..fe23199 --- /dev/null +++ b/src/Stadion/StadionState.java @@ -0,0 +1,13 @@ +package Stadion; + +public abstract class StadionState { + protected Stadion stadion; + + //In dieser Variante wird in der Abstract Class der Konstruktor + //gebaut, der in den Unterklassen nurnoch per "super" aufgerufen wird. + public StadionState(Stadion stadion){this.stadion = stadion;} + + + public abstract void leer(); + public abstract void ausverkauft(); +} diff --git a/src/Stadion/TestStadion.java b/src/Stadion/TestStadion.java new file mode 100644 index 0000000..3846f64 --- /dev/null +++ b/src/Stadion/TestStadion.java @@ -0,0 +1,17 @@ +package Stadion; + +import org.testng.annotations.Test; + +public class TestStadion { + + @Test + public void stateTester(){ + + Stadion stadion = new Stadion(); + + + + } + + +} diff --git a/src/Trainingsplatz/Belegt.java b/src/Trainingsplatz/Belegt.java new file mode 100644 index 0000000..e4966e8 --- /dev/null +++ b/src/Trainingsplatz/Belegt.java @@ -0,0 +1,21 @@ +package Trainingsplatz; + +public class Belegt implements State{ + private Trainingsplatz trainingsplatz; + + //2.Konstruktor + public Belegt(Trainingsplatz trainingsplatz){ + this.trainingsplatz=trainingsplatz; + } + + //Methode macht nicht anderes als die setState Methode aufzurufen. + @Override + public void verlassen() { + trainingsplatz.setState(new Frei(trainingsplatz)); + } + + @Override + public void betreten() { + + } +} diff --git a/src/Trainingsplatz/Frei.java b/src/Trainingsplatz/Frei.java new file mode 100644 index 0000000..8ab397c --- /dev/null +++ b/src/Trainingsplatz/Frei.java @@ -0,0 +1,20 @@ +package Trainingsplatz; + +public class Frei implements State { + private Trainingsplatz trainingsplatz; + + //1.Konstruktor + public Frei(Trainingsplatz trainingsplatz) { + + this.trainingsplatz=trainingsplatz; + } + + @Override + public void verlassen() { + } + + @Override + public void betreten() { + trainingsplatz.setState(new Belegt(trainingsplatz)); + } +} diff --git a/src/Trainingsplatz/State.java b/src/Trainingsplatz/State.java new file mode 100644 index 0000000..bd70b3d --- /dev/null +++ b/src/Trainingsplatz/State.java @@ -0,0 +1,10 @@ +package Trainingsplatz; + +public interface State { + + //Nachteil der Interface Variante: Hier gibt es keinen Konstruktor. + //Daher muss man 2 Konstruktoren in den Unterklassen schreiben. + + void verlassen(); + void betreten(); +} diff --git a/src/Trainingsplatz/Trainingsplatz.java b/src/Trainingsplatz/Trainingsplatz.java new file mode 100644 index 0000000..490c59d --- /dev/null +++ b/src/Trainingsplatz/Trainingsplatz.java @@ -0,0 +1,22 @@ +package Trainingsplatz; + +public class Trainingsplatz { + private State state; + + + public Trainingsplatz(){ + this.state= new Frei(this); + } + + public void setState(State state){ + this.state=state; + } + + public void betreten(){ + state.betreten(); + }; + + public void verlassen(){ + state.verlassen(); + }; +} diff --git a/src/Verein/Mannschaft.java b/src/Verein/Mannschaft.java new file mode 100644 index 0000000..000c325 --- /dev/null +++ b/src/Verein/Mannschaft.java @@ -0,0 +1,7 @@ +package Verein; + +public class Mannschaft { + + //Implementiere einen Iterator Pattern, der eine Liste der Mannschaftsnamen ausgibt + +}