public static int choose(String[] a) { String s = ""; for (int i = 0; i < a.length; i++) { s += "\t" + (i + 1) + " : " + a[i] + "\n"; } s += "Make your selection: "; System.out.print(s); int choice = Keyboard.readInt(); while (!(choice > 0 && choice < a.length + 1)) { System.out.print("Bad choice. Pick again: "); choice = Keyboard.readInt(); } return choice; }
public static void main(String[] args) { System.out.print("Enter infix: "); String infix = Keyboard.readString(); String result = generatePostfix(infix); System.out.println(result); }
public void prompt() { String prompt = "Choose your action:\n1 - Explore the town\n2 - Check your inventory\n3 - Go to the tavern\n4 - Go to the pub\n5 - Go to the next zone"; System.out.println(prompt); String input = Keyboard.readString(); if (input.equals("1")) { System.out.println("Under development"); prompt(); } else if (input.equals("2")) { System.out.println("You ruffle through your bag."); inventory.prompt(chara); prompt(); } else if (input.equals("3")) { System.out.println("Under development"); prompt(); } else if (input.equals("4")) { System.out.println("Under development"); prompt(); } else if (input.equals("5")) { exit(); } else { System.out.println("Try again"); prompt(); } }
/*==================================== plays one turn of 2048 ====================================*/ public void playTurn() { String s = Keyboard.readString(); if (s.equals("w") && swipeU()) addNewTile(); else if (s.equals("a") && swipeL()) addNewTile(); else if (s.equals("s") && swipeD()) addNewTile(); else if (s.equals("d") && swipeR()) addNewTile(); else return; // if the input is not w a s or d, do nothing // System.out.println("\n" + _board); System.out.println(_board); }
public void choice() { System.out.println( "1 - Answer the Riddle(Hint: Remember hearing anything wierd in the towns or something?)\n2 - Leave your camel behind\n"); String input = Keyboard.readString(); if (input.equals("1")) { EndOne end1 = new EndOne(chara); end1.play(); } else if (input.equals("2")) { EndTwo end2 = new EndTwo(chara); end2.play(); } else { System.out.println("Invalid input"); } }
public void SkillsDisplay(Monster m) { System.out.println( "1 - Charge: Costs 15 SpMp, This is a powerful charge and hit against your enemy!"); System.out.println( "2 - Blunt Bash: Costs 25 SpMp, This ability has a chance to stun your enemy!"); System.out.println( "3 - Precise Strike: Costs 20 SpMp, This ability has a chance to make your opponent bleed!"); System.out.println("4 - Go Back"); String input = Keyboard.readString(); if (input.equals("1")) { Charge(m); } else if (input.equals("2")) { BluntBash(m); } else if (input.equals("3")) { PreciseStrike(m); } else if (input.equals("4")) { action(m); } else { System.out.println("Invalid input"); SkillsDisplay(m); } }
public void action(Monster m) { System.out.println("1 - Basic Attack"); System.out.println("2 - Use a Skill"); System.out.println("3 - Use an Item"); System.out.println("4 - Run away"); String input = Keyboard.readString(); if (input.equals("1")) { System.out.println( "Your majestic blade bathes in crimson as you dig the blade into your foe"); attack(m); } else if (input.equals("2")) { SkillsDisplay(m); } else if (input.equals("3")) { System.out.println("Under development. Please understand fam"); action(m); } else if (input.equals("4")) { System.out.println("Under development. Please understand fam"); action(m); } else { System.out.println("Invalid input"); action(m); } }
public static String ask(String question) { System.out.print(question + ": "); String ans = Keyboard.readString(); return ans; }