initial commit
This commit is contained in:
commit
11a6cbcca8
7
.vscode/settings.json
vendored
Normal file
7
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"java.project.sourcePaths": ["src"],
|
||||||
|
"java.project.outputPath": "bin",
|
||||||
|
"java.project.referencedLibraries": [
|
||||||
|
"lib/**/*.jar"
|
||||||
|
]
|
||||||
|
}
|
18
README.md
Normal file
18
README.md
Normal file
@ -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).
|
BIN
bin/Main.class
Normal file
BIN
bin/Main.class
Normal file
Binary file not shown.
BIN
bin/Spieler/FieldPlayer.class
Normal file
BIN
bin/Spieler/FieldPlayer.class
Normal file
Binary file not shown.
BIN
bin/Spieler/Goalkeeper.class
Normal file
BIN
bin/Spieler/Goalkeeper.class
Normal file
Binary file not shown.
BIN
bin/Spieler/Mannschaft.class
Normal file
BIN
bin/Spieler/Mannschaft.class
Normal file
Binary file not shown.
BIN
bin/Spieler/Player.class
Normal file
BIN
bin/Spieler/Player.class
Normal file
Binary file not shown.
BIN
bin/Spieler/Position.class
Normal file
BIN
bin/Spieler/Position.class
Normal file
Binary file not shown.
BIN
bin/Spieler/TestPlayer.class
Normal file
BIN
bin/Spieler/TestPlayer.class
Normal file
Binary file not shown.
BIN
bin/Stadion/Empty.class
Normal file
BIN
bin/Stadion/Empty.class
Normal file
Binary file not shown.
BIN
bin/Stadion/Full.class
Normal file
BIN
bin/Stadion/Full.class
Normal file
Binary file not shown.
BIN
bin/Stadion/Stadion.class
Normal file
BIN
bin/Stadion/Stadion.class
Normal file
Binary file not shown.
BIN
bin/Stadion/StadionState.class
Normal file
BIN
bin/Stadion/StadionState.class
Normal file
Binary file not shown.
BIN
bin/Stadion/TestStadion.class
Normal file
BIN
bin/Stadion/TestStadion.class
Normal file
Binary file not shown.
BIN
bin/Trainingsplatz/Belegt.class
Normal file
BIN
bin/Trainingsplatz/Belegt.class
Normal file
Binary file not shown.
BIN
bin/Trainingsplatz/Frei.class
Normal file
BIN
bin/Trainingsplatz/Frei.class
Normal file
Binary file not shown.
BIN
bin/Trainingsplatz/State.class
Normal file
BIN
bin/Trainingsplatz/State.class
Normal file
Binary file not shown.
BIN
bin/Trainingsplatz/Trainingsplatz.class
Normal file
BIN
bin/Trainingsplatz/Trainingsplatz.class
Normal file
Binary file not shown.
BIN
bin/Verein/Mannschaft.class
Normal file
BIN
bin/Verein/Mannschaft.class
Normal file
Binary file not shown.
5
src/Main.java
Normal file
5
src/Main.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println("Hello world!");
|
||||||
|
}
|
||||||
|
}
|
57
src/Spieler/FieldPlayer.java
Normal file
57
src/Spieler/FieldPlayer.java
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
36
src/Spieler/Goalkeeper.java
Normal file
36
src/Spieler/Goalkeeper.java
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
8
src/Spieler/Mannschaft.java
Normal file
8
src/Spieler/Mannschaft.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package Spieler;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class Mannschaft {
|
||||||
|
|
||||||
|
}
|
22
src/Spieler/Player.java
Normal file
22
src/Spieler/Player.java
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
9
src/Spieler/Position.java
Normal file
9
src/Spieler/Position.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package Spieler;
|
||||||
|
|
||||||
|
public enum Position {
|
||||||
|
|
||||||
|
GOALKEEPER,
|
||||||
|
DEFENDER,
|
||||||
|
MIDFIELD,
|
||||||
|
STRIKER
|
||||||
|
}
|
45
src/Spieler/TestPlayer.java
Normal file
45
src/Spieler/TestPlayer.java
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
16
src/Stadion/Empty.java
Normal file
16
src/Stadion/Empty.java
Normal file
@ -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(){};
|
||||||
|
}
|
15
src/Stadion/Full.java
Normal file
15
src/Stadion/Full.java
Normal file
@ -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));}
|
||||||
|
}
|
12
src/Stadion/Stadion.java
Normal file
12
src/Stadion/Stadion.java
Normal file
@ -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;}
|
||||||
|
|
||||||
|
}
|
13
src/Stadion/StadionState.java
Normal file
13
src/Stadion/StadionState.java
Normal file
@ -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();
|
||||||
|
}
|
17
src/Stadion/TestStadion.java
Normal file
17
src/Stadion/TestStadion.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package Stadion;
|
||||||
|
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
public class TestStadion {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void stateTester(){
|
||||||
|
|
||||||
|
Stadion stadion = new Stadion();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
21
src/Trainingsplatz/Belegt.java
Normal file
21
src/Trainingsplatz/Belegt.java
Normal file
@ -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() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
20
src/Trainingsplatz/Frei.java
Normal file
20
src/Trainingsplatz/Frei.java
Normal file
@ -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));
|
||||||
|
}
|
||||||
|
}
|
10
src/Trainingsplatz/State.java
Normal file
10
src/Trainingsplatz/State.java
Normal file
@ -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();
|
||||||
|
}
|
22
src/Trainingsplatz/Trainingsplatz.java
Normal file
22
src/Trainingsplatz/Trainingsplatz.java
Normal file
@ -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();
|
||||||
|
};
|
||||||
|
}
|
7
src/Verein/Mannschaft.java
Normal file
7
src/Verein/Mannschaft.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package Verein;
|
||||||
|
|
||||||
|
public class Mannschaft {
|
||||||
|
|
||||||
|
//Implementiere einen Iterator Pattern, der eine Liste der Mannschaftsnamen ausgibt
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user