Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //NULL: How to compact: "while ((command.equals("n")) || (command...."
- //How to consolidate the intense number of "if (x == 10 && y == 10) {" etc. groups cleanly
- import java.util.Scanner;
- public class Testing {
- public static void name( String args[]) {
- Scanner input = new Scanner(System.in);
- System.out.println("What is your name, hero?");
- String hero1Name = input.nextLine();
- System.out.println("Welcome to Castle Alpha, " + hero1Name +"!");
- System.out.println("What is the name of your companions?");
- System.out.println("What is your companion's name?");
- String hero2Name = input.nextLine ();
- System.out.println("Welcome to the party, " + hero2Name + "!");
- }
- public static void main( String args[]) {
- Scanner input = new Scanner(System.in);
- int x = 10;
- int y = 10;
- int area = 1;
- // int numCommand = 0;
- String command = "";
- while (area == 1) {
- if (x == 10 && y == 10) {
- System.out.println(x + ", " + y + "\nYou are in the town centre.\nYou may go north, east, south, or west.");
- System.out.println("Command?");
- ////////////////Numerical movement system:
- // numCommand = input.nextInt();
- // System.out.println(command);
- // while ((numCommand == 8) || (numCommand == 2) || (numCommand == 4) || (numCommand == 6)) {
- // if (numCommand == 8) {
- // y = y + 1;
- // numCommand = 0;
- // } else if (numCommand == 2) {
- // y = y - 1;
- // numCommand = 0;
- // } else if (numCommand == 4) {
- // x = x - 1;
- // numCommand = 0;
- // } else if (numCommand == 6) {
- // x = x + 1;
- // numCommand = 0;
- // }
- ////////////////
- command = input.nextLine();
- while (!command.equals("")) {
- // while ((command.equals("n")) || (command.equals("s")) || (command.equals("e")) || (command.equals("w"))) {
- if (command.equals("n")) {
- y = y + 1;
- command = "";
- } else if (command.equals("s")) {
- // y = y - 1;
- System.out.println("Unavailable at this time.");
- command = "";
- } else if (command.equals("w")) {
- // x = x - 1;
- System.out.println("Unavailable at this time.");
- command = "";
- } else if (command.equals("e")) {
- // x = x + 1;
- System.out.println("Unavailable at this time.");
- command = "";
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- } if (x == 10 && y == 11) {
- System.out.println(x + ", " + y + "\nYou are on Main Street, north of the town centre.\nYou may go north or south.\nThere is a General Store to your west.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- // while ((command.equals("n")) || (command.equals("s")) || (command.equals("e")) || (command.equals("w"))) {
- if (command.equals("n")) {
- // y = y + 1;
- System.out.println("Unavailable at this time.");
- command = "";
- } else if (command.equals("s")) {
- y = y - 1;
- command = "";
- } else if (command.equals("w")) {
- // x = x - 1;
- System.out.println("Unavailable at this time.");
- command = "";
- } else if (command.equals("e")) {
- // x = x + 1;
- System.out.println("You cannot go that way.");
- command = "";
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- }
- // } else if (x == 10 && y == 9); {
- // System.out.println(x + ", " + y + "\nYou may go north or south.");
- }
- while (area == 2) {
- ////STATEMENT RESERVED FOR AREA 2
- }
- while ((area != 1) || (area != 2)) {
- ////TEMPORARY STATEMENT CONCERNING INVALID AREAS
- System.out.println("Area does not exist");
- }
- System.out.println("TERMINATING");
- }
- }
- // //CHARACTER VARIABLE DECLARATION
- // int health = 100;
- // int mana = 100;
- // int stamina = 100;
- // int STR = 10;
- // int CON = 10;
- // int INT = 10;
- // int WIS = 10;
- // int DEX = 10;
- // int CHA = 10;
Add Comment
Please, Sign In to add comment