Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
2715530b3a
|
@ -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) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class Language {
|
||||||
public void setOutputLanguage(String outputLanguage){
|
public void setOutputLanguage(String outputLanguage){
|
||||||
if(checkForValidLanguage(outputLanguage)){
|
if(checkForValidLanguage(outputLanguage)){
|
||||||
this.outputLanguage=outputLanguage;
|
this.outputLanguage=outputLanguage;
|
||||||
checkLanguage("Sprache auf Deutsch geändert","Language changed to english","Đã thay đổi ngôn ngữ sang tiếng Việt");
|
System.out.println(checkLanguage("Sprache auf Deutsch geändert","Language changed to english","Đã thay đổi ngôn ngữ sang tiếng Việt"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class Language {
|
||||||
if(outputLanguage.equals(germanShortCut)||outputLanguage.equals(englishShortCut)||outputLanguage.equals(vietnameseShortCut)){
|
if(outputLanguage.equals(germanShortCut)||outputLanguage.equals(englishShortCut)||outputLanguage.equals(vietnameseShortCut)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
checkLanguage("Diese Sprache ist nicht zulässig","This Language is not valid","Ngôn ngữ này không được phép");
|
System.out.println(checkLanguage("Diese Sprache ist nicht zulässig","This Language is not valid","Ngôn ngữ này không được phép"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class Language {
|
||||||
* @param player beinhaltet den Integer, welcher den Spieler representiert.
|
* @param player beinhaltet den Integer, welcher den Spieler representiert.
|
||||||
*/
|
*/
|
||||||
public void outputWinnerText(int player){
|
public void outputWinnerText(int player){
|
||||||
checkLanguage("Spieler "+player+" hat gewonnen! Gut gespiel","Player "+player+" won! Well played genius!","Người chơi "+player+" đã thắng. Làm tốt!");
|
System.out.println(checkLanguage("Spieler "+player+" hat gewonnen! Gut gespiel","Player "+player+" won! Well played genius!","Người chơi "+player+" đã thắng. Làm tốt!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,7 +64,7 @@ public class Language {
|
||||||
* @param nextPlayer beinhaltet den Integer, welcher den Spieler representiert.
|
* @param nextPlayer beinhaltet den Integer, welcher den Spieler representiert.
|
||||||
*/
|
*/
|
||||||
public void outputNextPlayerText(int nextPlayer){
|
public void outputNextPlayerText(int nextPlayer){
|
||||||
checkLanguage("Du bist dran "+ nextPlayer,"It's your turn "+nextPlayer,"Đến lượt bạn "+nextPlayer);
|
System.out.println(checkLanguage("Du bist dran "+ nextPlayer,"It's your turn "+nextPlayer,"Đến lượt bạn "+nextPlayer));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,7 +72,7 @@ public class Language {
|
||||||
* Diese Methode informiert den Nutzer über eine Konsolenausgabe, falls ein falsches Feld ausgewählt wird.
|
* Diese Methode informiert den Nutzer über eine Konsolenausgabe, falls ein falsches Feld ausgewählt wird.
|
||||||
*/
|
*/
|
||||||
public void outputWrongFieldSelected(){
|
public void outputWrongFieldSelected(){
|
||||||
checkLanguage("Dieses Feld ist nicht zulässig","This Field is not valid","Trường này không được phép");
|
System.out.println(checkLanguage("Dieses Feld ist nicht zulässig","This Field is not valid","Trường này không được phép"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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