Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // CW
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args)
- {
- final int SIZE = 8;
- Scanner in = new Scanner(System.in);
- int row, col;
- int points = 0;
- System.out.printf("The size of your board is %d.\n", SIZE);
- Game game = new Game(SIZE);
- System.out.printf("Keep entering pairs of numbers to represent your coin's location: ");
- row = in.nextInt();
- col = in.nextInt();
- while(row != -1 && col != -1)
- {
- points += game.Move(row, col);
- System.out.printf("Next: ");
- row = in.nextInt();
- col = in.nextInt();
- }
- System.out.printf("Game over. You have %d points!", points);
- in.close();
- }
- }
- // Next class
- public class Game
- {
- int[][] matrix;
- public Game(int size)
- {
- matrix = new int[size][size];
- }
- public int Move(int row, int col)
- {
- int result = 0;
- if(col > row)
- result = 1;
- else if(col < row)
- result = -1;
- else if(col == row)
- result = 5;
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement