LanguageTest.java clean code update

This commit is contained in:
Andrin Fassbind 2021-10-09 17:17:59 +02:00
parent 105471350d
commit aeceb51565
1 changed files with 30 additions and 12 deletions

View File

@ -14,8 +14,8 @@ public class Language {
private final String englishShortCut = "en";
private final String vietnameseShortCut = "vn";
public Language(String outputLanguage){
if(checkForValidLanguage(outputLanguage)){
public Language(String outputLanguage) {
if(checkForValidLanguage(outputLanguage)) {
this.outputLanguage=outputLanguage;
}
}
@ -26,8 +26,8 @@ public class Language {
* Sie informiert den Nutzer entsprechend.
* @param outputLanguage beinhaltet den Sprachkürzel, welche neu gewählt werden sollte.
*/
public void setOutputLanguage(String outputLanguage){
if(checkForValidLanguage(outputLanguage)){
public void setOutputLanguage(String outputLanguage) {
if(checkForValidLanguage(outputLanguage)) {
this.outputLanguage=outputLanguage;
System.out.println(checkLanguage("Sprache auf Deutsch geändert","Language changed to english","Đã thay đổi ngôn ngữ sang tiếng Việt"));
}
@ -41,11 +41,14 @@ public class Language {
* @param outputLanguage Enthält den Sprachkürzel, auf welche die Sprachausgabe gesetzt werden sollte.
* @return boolean True falls Sprachkürzel valide andernfalls false
*/
private boolean checkForValidLanguage(String outputLanguage){
if(outputLanguage.equals(germanShortCut)||outputLanguage.equals(englishShortCut)||outputLanguage.equals(vietnameseShortCut)){
private boolean checkForValidLanguage(String outputLanguage) {
if(outputLanguage.equals(germanShortCut)||outputLanguage.equals(englishShortCut)||outputLanguage.equals(vietnameseShortCut)) {
return true;
}
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"));
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;
}
@ -80,7 +83,10 @@ public class Language {
* @param player beinhaltet den Integer, welcher den Spieler representiert.
*/
public void outputWinnerText(int player) {
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!"));
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!"));
}
/**
@ -88,7 +94,10 @@ public class Language {
* Diese Methode gibt den Text aus, wenn das Spiel zu ende ist.
*/
public void outputGameOverText(){
System.out.println(checkLanguage("Das Spiel ist zu ende!","The Game has finished!","Trò chơi kết thúc rồi!"));
System.out.println(checkLanguage(
"Das Spiel ist zu ende!",
"The Game has finished!",
"Trò chơi kết thúc rồi!"));
}
/**
@ -96,7 +105,10 @@ public class Language {
* Diese Methode gibt den Text aus, falls es Unentschieden ist.
*/
public void outputTieText(){
System.out.println(checkLanguage("Wir haben keinen Gewinner. Es ist unentschieden","We have no Winner. It's a tie","Chúng tôi không có người chiến thắng."));
System.out.println(checkLanguage(
"Wir haben keinen Gewinner. Es ist unentschieden",
"We have no Winner. It's a tie",
"Chúng tôi không có người chiến thắng."));
}
/**
@ -105,7 +117,10 @@ public class Language {
* @param nextPlayer beinhaltet den Integer, welcher den Spieler representiert.
*/
public void outputNextPlayerText(int nextPlayer){
System.out.println(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));
}
/**
@ -113,7 +128,10 @@ public class Language {
* Diese Methode informiert den Nutzer über eine Konsolenausgabe, falls ein falsches Feld ausgewählt wird.
*/
public void outputWrongFieldSelected(){
System.out.println(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"));
}
/**