Language Class has been implementet.
This commit is contained in:
parent
98c94cee62
commit
8cd982d81b
|
@ -1,10 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="RunConfigurationProducerService">
|
|
||||||
<option name="ignoredProducers">
|
|
||||||
<set>
|
|
||||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
/**
|
||||||
|
* Diese Klasse instanziert ein Objekt des Types Sprache. Dieses Objekt erlaubt
|
||||||
|
* Sprachausgaben in 3 verschiedenen Sprachen.
|
||||||
|
* Die Sprachausgaben helfen dem Nutzer bei der Orientierung und geben an den Spielfortschritt an.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class Language {
|
||||||
|
|
||||||
|
//Enthält gewählte Sprache
|
||||||
|
private String outputLanguage = "de";
|
||||||
|
|
||||||
|
//Gibt mögliche Sprachen vor
|
||||||
|
private String germanShortCut = "de";
|
||||||
|
private String englishShortCut = "en";
|
||||||
|
private String vietnameseShortCut = "vn";
|
||||||
|
|
||||||
|
public Language(String outputLanguage){
|
||||||
|
if(checkForValidLanguage(outputLanguage)){
|
||||||
|
this.outputLanguage=outputLanguage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diese Methode setzt das Datenfeld neu, falls es sich um eine Valide Sprache handelt.
|
||||||
|
* Sie informiert den Nutzer entsprechend
|
||||||
|
* @param outputLanguage
|
||||||
|
*/
|
||||||
|
public void setOutputLanguage(String outputLanguage){
|
||||||
|
if(checkForValidLanguage(outputLanguage)){
|
||||||
|
this.outputLanguage=outputLanguage;
|
||||||
|
if(outputLanguage.equals(germanShortCut)){
|
||||||
|
System.out.println("Sprache auf Deutsch geändert");
|
||||||
|
}else if(outputLanguage.equals(englishShortCut)){
|
||||||
|
System.out.println("Language changed to english");
|
||||||
|
}else if(outputLanguage.equals(vietnameseShortCut)){
|
||||||
|
System.out.println("Đã thay đổi ngôn ngữ sang tiếng Việt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diese Methode prüft ob es sich um eine Valide Sprache handelt.
|
||||||
|
* Gibt true zurück,wenn valide.Sonst false und entsprechende Konsolenausgabe.
|
||||||
|
* @param outputLanguage
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public boolean checkForValidLanguage(String outputLanguage){
|
||||||
|
if(outputLanguage.equals(germanShortCut)||outputLanguage.equals(englishShortCut)||outputLanguage.equals(vietnameseShortCut)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(this.outputLanguage.equals(germanShortCut)){
|
||||||
|
System.out.println("Diese Sprache ist nicht zulässig");
|
||||||
|
}else if(this.outputLanguage.equals(englishShortCut)){
|
||||||
|
System.out.println("This Language is not valid");
|
||||||
|
}else if(this.outputLanguage.equals(vietnameseShortCut)) {
|
||||||
|
System.out.println("Ngôn ngữ này không được phép");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diese Methode gibt den Gewinnertext aus.
|
||||||
|
* @param player
|
||||||
|
*/
|
||||||
|
public void outputWinnerText(int player){
|
||||||
|
if(outputLanguage.equals(germanShortCut)){
|
||||||
|
System.out.println("############### Wir haben einen Gewinner ###############");
|
||||||
|
System.out.printf("Spieler %d hat gewonnen! Gut gespielt%n",player);
|
||||||
|
}else if(outputLanguage.equals(englishShortCut)){
|
||||||
|
System.out.println("############### Winner Winner Chicken Dinner ###############");
|
||||||
|
System.out.printf("Player %d won! Well played genius%n",player);
|
||||||
|
}else if(outputLanguage.equals(vietnameseShortCut)){
|
||||||
|
System.out.println("############### Chúng ta có một người chiến thắng ###############");
|
||||||
|
System.out.printf("Người chơi %d đã thắng. Làm tốt!%n",player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diese Methode informiert den Nutzer über den Spieler, welcher am Zug ist.
|
||||||
|
* @param nextPlayer
|
||||||
|
*/
|
||||||
|
public void outputNextPlayerText(int nextPlayer){
|
||||||
|
if(outputLanguage.equals(germanShortCut)){
|
||||||
|
System.out.printf("Du bist dran %d%n",nextPlayer);
|
||||||
|
}else if(outputLanguage.equals(englishShortCut)){
|
||||||
|
System.out.printf("It's your turn %d%n",nextPlayer);
|
||||||
|
}else if(outputLanguage.equals(vietnameseShortCut)){
|
||||||
|
System.out.printf("Đến lượt bạn %d%n",nextPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diese Methode informiert den Nutzer falls ein falsches Feld ausgewählt wird.
|
||||||
|
*/
|
||||||
|
public void outputWrongFieldSelected(){
|
||||||
|
if(outputLanguage.equals(germanShortCut)){
|
||||||
|
System.out.println("Dieses Feld ist nicht zulässig");
|
||||||
|
}else if(outputLanguage.equals(englishShortCut)){
|
||||||
|
System.out.println("This Field is not valid");
|
||||||
|
}else if(outputLanguage.equals(vietnameseShortCut)){
|
||||||
|
System.out.println("Trường này không được phép");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue