-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMarcoPolo.java
More file actions
73 lines (60 loc) · 1.75 KB
/
MarcoPolo.java
File metadata and controls
73 lines (60 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//Dr. JJ Shepherd
import java.util.*;
public class MarcoPolo {
public static final int BOARD_SIZE = 10; //Board Size
//Enumerations
enum Spaces {
Empty,
Player,
Goal,
Walked_Path
};
public static void main(String[] args) {
int numberOfMoves = 0; //Counter
int pX = 0; //Positon Horizontal
int pY = 0; //Position Vertical
Random r = new Random();
//Get random variable for goals
int gX = r.nextInt(BOARD_SIZE);
int gY = r.nextInt(BOARD_SIZE);
Scanner keyboard = new Scanner(System.in); //Get input
Spaces[][] board = new Spaces[BOARD_SIZE][BOARD_SIZE]; //Board
//Set board to Empty
for(int i = 0; i < board.length; i++) {
for(int j = 0; j < board[i].length; j++) {
board[i][j] = Spaces.Empty;
}
}
//Welcome user
System.out.println("Hey you\nHow goes it?\nLet's play the Marco Polos.");
boolean gameOver = false;
while(gameOver == false) {
//Draw the board
//Double for loop for multidimensional array
for(int i = 0; i < board.length; i++) {
for(int j = 0; j < board[i].length; j++) {
//Switch case for iterating and displaying board.
switch(board[i][j]) {
case Empty:
System.out.print("_");
break;
case Player:
System.out.print("X");
break;
case Goal:
System.out.print("_");
break;
case Walked_Path:
System.out.print("#");
break;
default:
System.out.print("?");
}
}
//To make rows(Not sure if this was in class.)
System.out.println("");
}
int test = keyboard.nextInt();
}//Game loop
}
}