Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, I am a fresh learner in Java and trying to make an 8 by 8 Reversi/Othello. Now I'm getting a few confusions - and

Hi, I am a fresh learner in Java and trying to make an 8 by 8 Reversi/Othello. Now I'm getting a few confusions - and write a class called Reversi that contains the main method. The main method creates a Game object and launches the game.

public static void start(Game g): This method essentially launches the game. The Black player will always start the game. This method has to handle reading input from the user in order to make a move.

You are required to provide an implementation for the following methods:

In this case, it will take two inputs (row, column) from the user to represent a position that they want to move to. Then, it needs to check whether this position is within this players valid moves or not. If it is not, you need to keep asking the user until you get a valid position - use the public static boolean contains(Point[] points, Point p) function for that. If the user inputs exit, the game terminates.

Moreover, this method needs to handle cases where one of the players might have no valid moves, and has to skip his turn. Finally, this method should report the winner at the end of the game. The game terminates either when both players have no valid moves, or when the board is full and there is no empty positions - use the public static boolean isEmpty(Point[] P) for this purpose. It also terminates if the players inputs exit.

public static boolean isEmpty(Point[] P): This method should check if there are any possible moves in the current board or not. It checks whether the board is full and there is no empty positions.

public static boolean contains(Point[] points, Point p): This method should check if a given point/position in the board is within the given array of points. This is used to check if the users input is among their valid set of positions (moves) or not.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

OUTCOME 2 Describe how a training needs assessment should be done.

Answered: 1 week ago

Question

13. You always should try to make a good first impression.

Answered: 1 week ago