completed and translated Javadocs into german.
This commit is contained in:
parent
2a10ee86d1
commit
0d4871c9d6
|
@ -1,18 +1,18 @@
|
||||||
|
/**
|
||||||
|
* Klasse um den Zustand der Felder 1-9 zu speichern und zu verändern, sowie das Spielfeld auszugeben.
|
||||||
|
*/
|
||||||
public class Gamefield {
|
public class Gamefield {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Int Werte für die Felder 1-9 (0 --> noch nicht gesetzt, 1 --> gesetzt von Spieler 1, 2 --> gesetzt von Spieler 2)
|
||||||
|
*/
|
||||||
private int field1 = 0, field2 = 0, field3 = 0, field4 = 0, field5 = 0, field6 = 0, field7 = 0, field8 = 0, field9 = 0;
|
private int field1 = 0, field2 = 0, field3 = 0, field4 = 0, field5 = 0, field6 = 0, field7 = 0, field8 = 0, field9 = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor of class Gamefield
|
* Methode um ein Fled zu setzen.
|
||||||
*/
|
* @param field das Feld welches gesetzt werden soll (1-9)
|
||||||
Gamefield() {}
|
* @param player der Spieler der das Feld setzt (1 oder 2)
|
||||||
|
* @return true --> das feld wurde gesetzt, false --> das feld wurde nicht gesetzt,das es nicht existiert oder bereits gsetzt war.
|
||||||
/**
|
|
||||||
* Method to set a field when it is set from player
|
|
||||||
* @param field the field which should be set. (1-9)
|
|
||||||
* @param player the player who sets the field (1 or 2)
|
|
||||||
* @return true --> field is set, false --> field isn't set because it's already set or it doesn't exist.
|
|
||||||
*/
|
*/
|
||||||
public boolean setField(int field, int player) {
|
public boolean setField(int field, int player) {
|
||||||
if(field == 1 && field1 == 0) {
|
if(field == 1 && field1 == 0) {
|
||||||
|
@ -43,16 +43,15 @@ public class Gamefield {
|
||||||
field9 = player;
|
field9 = player;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false; //if field is already set or it doesn't exist.
|
return false; //Wenn das Feld nicht existiert oder bereits gesetzt wurde.
|
||||||
}
|
}
|
||||||
return true; //if change is done
|
return true; //Wenn das Feld gesetzt wurde.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Methode um ein Feld abzufragen.
|
||||||
* @param field the number of the requested field
|
* @param field die Nummer des Feldes
|
||||||
* @return integer of the player, which has set the requested field (1 -> Player 1, 2 -> Player 2, -1 --> the requested field doens't exist.)
|
* @return Der Spieler der das Feld gesetzt hat oder 0 wenn es noch nicht gesetz wurde
|
||||||
*/
|
*/
|
||||||
public int getField(int field) {
|
public int getField(int field) {
|
||||||
if(field == 1) {
|
if(field == 1) {
|
||||||
|
@ -82,11 +81,11 @@ public class Gamefield {
|
||||||
else if(field == 9) {
|
else if(field == 9) {
|
||||||
return field9;
|
return field9;
|
||||||
}
|
}
|
||||||
return -1; //if the requested field doesn't exist, -1 will be returned.
|
return -1; //wenn das feld nicht existiert
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to print field
|
* Methode um das Spielfeld auszugeben.
|
||||||
*/
|
*/
|
||||||
public void outputField() {
|
public void outputField() {
|
||||||
System.out.println(getSymbol(field1) + "|" + getSymbol(field2) + "|" + getSymbol(field3));
|
System.out.println(getSymbol(field1) + "|" + getSymbol(field2) + "|" + getSymbol(field3));
|
||||||
|
@ -98,7 +97,7 @@ public class Gamefield {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param player number of player who has set the field (1 or 2)
|
* @param player Der Spieler der das Feld gesetzt hat. (1 oder 2)
|
||||||
* @return the Symbol of the player who has set the field (X or O)
|
* @return the Symbol of the player who has set the field (X or O)
|
||||||
*/
|
*/
|
||||||
private String getSymbol(int player) {
|
private String getSymbol(int player) {
|
||||||
|
|
|
@ -6,8 +6,4 @@ public class TicTacToe {
|
||||||
gamefield.setField(7, 2);
|
gamefield.setField(7, 2);
|
||||||
gamefield.outputField();
|
gamefield.outputField();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TicTacToe(String int1, int int2) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue