Hallo Leute.
Ich versuche mich gerade an einem Text-Adventure, und daher soll das Programm Strings vergleichen können.
Ich habe soweit auch den Code fertig:
Wenn man "look" eingiebt, dann stimmt die Ausgabe auch.
Ausgabe:
look
You look arround in the Room.
To your right is a door.
Allerdings wenn man jetzt "look arround" eingiebt, dann erfolgen zwei Prüfungen.
Ausgabe:
look arround
look
You look arround in the Room.
To your right is a door.
arround
What?
Wie kriege ich es hin das hier die selbe Ausgabe erfolgt, also dass wenn er einmal was erkennt den rest weglässt?
Ich versuche mich gerade an einem Text-Adventure, und daher soll das Programm Strings vergleichen können.
Ich habe soweit auch den Code fertig:
Java:
playerIn = sc.next();
System.out.println(playerIn); //kommt später weg.
if(playerIn.contains("look")){
System.out.println("You look arround in the Room.");
System.out.println("To your right is a door.");
}else{
System.out.println("What?");
}
Wenn man "look" eingiebt, dann stimmt die Ausgabe auch.
Ausgabe:
look
You look arround in the Room.
To your right is a door.
Allerdings wenn man jetzt "look arround" eingiebt, dann erfolgen zwei Prüfungen.
Ausgabe:
look arround
look
You look arround in the Room.
To your right is a door.
arround
What?
Wie kriege ich es hin das hier die selbe Ausgabe erfolgt, also dass wenn er einmal was erkennt den rest weglässt?
Zuletzt bearbeitet: