Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Movement {
- public static void main(String args[]) {
- Scanner input = new Scanner(System.in);
- int x = 10;
- int y = 10;
- int area = 1;
- String command = "";
- while (area == 1) {
- if (command.equals("quit")) {
- area = 0;
- //######################################################################
- //######################################################################
- } else if (x == 1 && y == 1) {
- System.out.println(x + ", " + y + "\nYou are at the intersection of Plum Alley and West Wall Street.\nYou may go east or south.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("s")) {
- ++y;
- command = "";
- } else if (command.equals("w")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("e")) {
- ++x;
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 1 && y == 2) {
- System.out.println(x + ", " + y + "\nYou are on West Wall Street.\nYou may go north or south.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- --y;
- command = "";
- } else if (command.equals("s")) {
- ++y;
- command = "";
- } else if (command.equals("w")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("e")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 2 && y == 3) {
- System.out.println(x + ", " + y + "\nTEXT");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("s")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("w")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("e")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 2 && y == 1) {
- System.out.println(x + ", " + y + "\nYou are on Plum Alley.\nYou may go east or west.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("s")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("w")) {
- --x;
- command = "";
- } else if (command.equals("e")) {
- ++x;
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 3 && y == 1) {
- System.out.println(x + ", " + y + "\nYou are on Plum Alley.\nYou may go east or west.\nThere is a Potions shop to your south.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("s")) {
- System.out.println("Not yet implemented.");
- command = "";
- } else if (command.equals("w")) {
- --x;
- command = "";
- } else if (command.equals("e")) {
- ++x;
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 4 && y == 1) {
- System.out.println(x + ", " + y + "\nYou are on Plum Alley.\nYou may go east or west.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("s")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("w")) {
- --x;
- command = "";
- } else if (command.equals("e")) {
- ++x;
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 5 && y == 1) {
- System.out.println(x + ", " + y + "\nYou are at the intersection of Plum Alley and Orchid Lane.\nYou may go east, south, or west.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("s")) {
- // ++y;
- System.out.println("ERROR: UNAVAILABLE: Unidentified Error.");
- command = "";
- } else if (command.equals("w")) {
- --x;
- command = "";
- } else if (command.equals("e")) {
- ++x;
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################//
- //################################ FAIL ################################//
- //######################################################################//
- //################################ FAIL ################################//
- //######################################################################//
- // } else if (x == 5 && y == 2) {
- // System.out.println(x + ", " + y + "\nYou are on Orchid Lane.\nYou may go north or south.");
- // System.out.println("Command?");
- // command = input.nextLine();
- // while (!command.equals("")) {
- // if (command.equals("n")) {
- // --y;
- // } else if (command.equals("s")) {
- // ++y;
- // command = "";
- // } else if (command.equals("w")) {
- // System.out.println("You cannot go that way.");
- // command = "";
- // } else if (command.equals("e")) {
- // System.out.println("You cannot go that way.");
- // command = "";
- // } else if (command.equals("quit")) {
- // command = "quit";
- // break;
- // } else {
- // System.out.println("Unrecognised command. Try again.");
- // command = input.nextLine();
- // }
- // }
- //######################################################################
- } else if (x == 6 && y == 1) {
- System.out.println(x + ", " + y + "\nYou are on Plum Alley.\nYou may go east or west.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("s")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("w")) {
- --x;
- command = "";
- } else if (command.equals("e")) {
- ++x;
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 7 && y == 1) {
- System.out.println(x + ", " + y + "\nYou are on Plum Alley.\nYou may go east, or west.\nThere is a Magic shop to your south.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("s")) {
- System.out.println("Not yet implemented.");
- command = "";
- } else if (command.equals("w")) {
- --x;
- command = "";
- } else if (command.equals("e")) {
- ++x;
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 8 && y == 1) {
- System.out.println(x + ", " + y + "\nYou are at the intersection of Plum Alley and Cherry Street.\nYou may go south or west.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("s")) {
- ++y;
- command = "";
- } else if (command.equals("w")) {
- --x;
- command = "";
- } else if (command.equals("e")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 8 && y == 2) {
- System.out.println(x + ", " + y + "\nYou are on Cherry Street.\nYou may go north or south.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- --y;
- command = "";
- } else if (command.equals("s")) {
- ++y;
- command = "";
- } else if (command.equals("w")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("e")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 8 && y == 3) {
- System.out.println(x + ", " + y + "\nYou are on Cherry Street.\nYou may go north, or south into the Market.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- --y;
- command = "";
- } else if (command.equals("s")) {
- ++y;
- command = "";
- } else if (command.equals("w")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("e")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 8 && y == 4) {
- System.out.println(x + ", " + y + "\nYou are on Cherry Street.\nYou may go north, or south into the Market.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- --y;
- command = "";
- } else if (command.equals("s")) {
- ++y;
- command = "";
- } else if (command.equals("w")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("e")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 8 && y == 5) {
- System.out.println(x + ", " + y + "\nYou are in the Market.\nYou may go north, east, south, or west.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- --y;
- command = "";
- } else if (command.equals("s")) {
- ++y;
- command = "";
- } else if (command.equals("w")) {
- --x;
- command = "";
- } else if (command.equals("e")) {
- ++x;
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 9 && y == 5) {
- System.out.println(x + ", " + y + "\nYou are in the Market.\nYou may go east, south, or west.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("s")) {
- ++y;
- command = "";
- } else if (command.equals("w")) {
- --x;
- command = "";
- } else if (command.equals("e")) {
- ++x;
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 9 && y == 9) {
- command = "";
- System.out.println("Welcome to the General Store!");
- System.out.println("Would you like to buy or sell?");
- System.out.println("--Buy");
- System.out.println("--Sell");
- System.out.println("--Leave");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("buy")) {
- } else if (command.equals("sell")) {
- } else if (command.equals("leave")) {
- command = "";
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- ++x;
- //#####################################################################
- } else if (x == 10 && y == 1) {
- System.out.println(x + ", " + y + "\nYou are on North Avenue.\nYou may go south, or north into the Castle.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- System.out.println("CASTLE:CASTLE:NOT YET IMPLEMENTED");
- command = "";
- } else if (command.equals("s")) {
- ++y;
- command = "";
- } else if (command.equals("w")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("e")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 10 && y == 2) {
- System.out.println(x + ", " + y + "\nYou are on North Avenue.\nYou may go north or south.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- --y;
- command = "";
- } else if (command.equals("s")) {
- ++y;
- command = "";
- } else if (command.equals("w")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("e")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 10 && y == 3) {
- System.out.println(x + ", " + y + "\nYou are at the intersection of White street and North Avenue.\nYou may go north, east, or south.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- --y;
- command = "";
- } else if (command.equals("s")) {
- ++y;
- command = "";
- } else if (command.equals("w")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("e")) {
- ++x;
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 10 && y == 4) {
- System.out.println(x + ", " + y + "\nYou are on North Avenue.\nYou may go north or south.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- --y;
- command = "";
- } else if (command.equals("s")) {
- ++y;
- command = "";
- } else if (command.equals("w")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("e")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 10 && y == 5) {
- System.out.println(x + ", " + y + "\nYou are on North Avenue.\nYou may go north, south, or west into the Market.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- --y;
- command = "";
- } else if (command.equals("s")) {
- ++y;
- command = "";
- } else if (command.equals("w")) {
- --x;
- command = "";
- } else if (command.equals("e")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 10 && y == 6) {
- System.out.println(x + ", " + y + "\nYou are on North Avenue.\nYou may go north, south, or west into the Market.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- --y;
- command = "";
- } else if (command.equals("s")) {
- ++y;
- command = "";
- } else if (command.equals("w")) {
- --x;
- command = "";
- } else if (command.equals("e")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 10 && y == 7) {
- System.out.println(x + ", " + y + "\nYou are on North Avenue.\nYou may go north or south.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- --y;
- command = "";
- } else if (command.equals("s")) {
- ++y;
- command = "";
- } else if (command.equals("w")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("e")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 10 && y == 8) {
- System.out.println(x + ", " + y + "\nYou are on North Avenue.\nYou may go north or south.");
- System.out.println("Command?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- --y;
- command = "";
- } else if (command.equals("s")) {
- ++y;
- command = "";
- } else if (command.equals("w")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("e")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //######################################################################
- } else if (x == 10 && y == 9) {
- System.out.println(x + ", " + y + "\nYou are on North Avenue, 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("")) {
- if (command.equals("n")) {
- --y;
- command = "";
- } else if (command.equals("s")) {
- ++y;
- command = "";
- } else if (command.equals("w")) {
- System.out.println("Not yet implemented.");//--x;
- command = "";
- } else if (command.equals("e")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- //#######################################################################
- } else 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?");
- command = input.nextLine();
- while (!command.equals("")) {
- if (command.equals("n")) {
- --y;
- command = "";
- } else if (command.equals("s")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("w")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("e")) {
- System.out.println("You cannot go that way.");
- command = "";
- } else if (command.equals("quit")) {
- command = "quit";
- break;
- } else {
- System.out.println("Unrecognised command. Try again.");
- command = input.nextLine();
- }
- }
- } else {
- System.out.println("TERMINATING: ERROR: 404.1: Coordinates Not Found");
- System.exit(0);
- }
- }
- if (area == 0) {
- System.out.println("TERMINATING: QUIT");
- System.exit(0);
- }
- while ((area != 0) || (area != 1) || (area != 2)) {
- ////TEMPORARY STATEMENT CONCERNING INVALID AREAS
- System.out.println("TERMINATING: ERROR: 404.0: Area Not Found");
- System.exit(0);
- }
- System.out.println("TERMINATING: ERROR: 1: Improper lead to escape primary while loop");
- System.exit(0);
- }
- }
Add Comment
Please, Sign In to add comment