I am trying to create a cipher game. Our teacher said there should be 2 modes. First mode should be a normal mode where the quote will be choosen randomly. Second mode is the test mode which lets you choose a quote. In the test mode I can't go further because it says terminated, I don't know what the problem is.
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
public class main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Random random = new Random();
char plainText[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'r', 'x', 'y', 'z'};
char cipherText[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'r', 'x', 'y', 'z'};
System.out.println("Please choose a mod: ");
System.out.println("1.Normal Mode");
System.out.println("2.Test Mode");
int user = in.nextInt();
String[] strings = {
"So many books so little time ",
"Be the change that you wish to see in the world ",
"No one can make you feel inferior without your consent",
"Love for all hatred for none ",
"Die with memories not dreams",
"Aspire to inspire before we expire",
"Whatever you do do it well",
"What we think we become ",
"Be so good they cant ignore you ",
};
String randomString = strings[random.nextInt(strings.length)];
if (user==1) {
System.out.println(randomString);
for (int a=0;a<randomString.length();a++) {
for (int i=0; i<plainText.length;i++) {
if(plainText[i] == (randomString.charAt(a))) {
System.out.print(cipherText[i]);
}
}
}
}
else if(user==2) {
System.out.println("Please choose one quote: ");
String islemler = "1. So many books so little time\n" +
"2. Be the change that you wish to see in the world\n" +
"3. No one can make you feel inferior without your consent\n" +
"4. Love for all hatred for none\n" +
"5. Die with memories not dreams\n" +
"6. Aspire to inspire before we expire\n" +
"7. Whatever you do do it well\n" +
"8. What we think we become\n" +
"9. Be so good they cant ignore you\n";
System.out.println(islemler);
String islem = in.nextLine();
switch(islem) {
case "1":
System.out.println("So many books so little time");
case "2":
System.out.println("Be the change that you wish to see in the world");
case "3":
System.out.println(" No one can make you feel inferior without your consent");
case "4":
System.out.println(" Love for all hatred for none");
case "5":
System.out.println("Die with memories not dreams");
case "6":
System.out.println("Aspire to inspire before we expire");
case "7":
System.out.println("Whatever you do do it well");
case "8":
System.out.println("What we think we become");
case "9":
System.out.println(" Be so good they cant ignore you");
}
}
else {
System.out.println("Please restart the game");
}
}
}