Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CODE MUST BE WRITTEN IN THE WAY LAID OUT IN INSTRUCTIONS, CLASSES LISTED BELOW MUST BE IN CODE. THERE MUST BE: TILE Class GAMEBOARD Class

CODE MUST BE WRITTEN IN THE WAY LAID OUT IN INSTRUCTIONS, CLASSES LISTED BELOW MUST BE IN CODE.

THERE MUST BE:

TILE Class

GAMEBOARD Class

OTHELLO Class

image text in transcribed

image text in transcribed

The Assignment Write a text-based implementation of Othello. Your program should start by displaying the initial configuration of the board as drawn above. Then allow the two players to alternate turns by placing pieces onto the board. If a player cannot make a valid move, the game should automatically forfeit the turn to the other player. The game should continue until neither player can make a valid move. Once this occurs, determine and display the winner of the game.

Class Design A Tile class to represent a single tile on the Othello board. This class should include (but is not limited to) the following parts: o Instance variables State of the tile it can be empty, black, or white o Methods Flipping the tile to the opposite color A toString method that returns how the tile should be displayed

A GameBoard class to represent the entire set of 64 tiles. GameBoard is used to store the current state of the game. This class should include (but is not limited to) the following parts: o Instance variables A 2-D array of Tile objects The number of rows and columns on the board (both of these will be 8 for this game, but you should write your code in such a way that it can easily be changed to other dimensions) o Methods A method that counts the pieces of a specific color present on the board A method that places a piece of a specific color at a specific location, flipping any appropriate pieces of the opposite color A method that determines whether a valid move exists on the board for a specific color A method that determines the current state of the game (still in progress, victory by black, victory by white, or a tie) A toString method that returns how the board should be displayed

An Othello class that serves as the main client program for the game. This class should include (but is not limited to) the following parts: o Instance variables A GameBoard object to store the state of the game A Scanner object to read user input o Methods A main method that is executed to start the game

Note that all user input should be located only in the Othello class. The idea is that the core game objects (Tile and GameBoard) should be independent of the games user interface. If you wanted to make a graphical version of Othello, youd be able to use the existing classes and make changes only to the Othello class! Implement error checking on all user inputs, to the extent that was covered in COMP 1900. For example, when a player makes a move, you should prevent things like: Entering coordinates that are outside of the board Entering coordinates that already contain a piece Entering coordinates that would not result in any outflanking (this is not a valid move)

Background Information Othello (also known as Reversi) is a two-player game played on an 8x8 board similar to that used in chess or checkers Each player chooses a color (black or white), and the objective of the game is to accummlate as many pieces of your own color as possible. How to plav The game starts in the following configuration: Players alternate turns, with black moving first. A move consists of placing a piece of your color on the board in such a way that it outflanksone or more of your opponent's pieces. Outflanking means creating a straight line of your opponent's pieces that are bordered on both ends by your pieces. This may be done horizontally, vertically, or diagonally. Outflanking your opponent's pieces flips them to your color. If a player cannot outflank any of his/her opponent's pieces during a turn, s/he ust forfeit that tum pass his/ber turn if any valid moves exist. Aplayer may not The game ends when neither player is able to make a valid move. (This is guaranteed to happen when the board is full, but it may occur before that. For example, if one player manages to flip all of his/ber opponent's pieces before the board is full, the opponent is left with no valid moves.) The winner is the player with the higher number of pieces on the board Background Information Othello (also known as Reversi) is a two-player game played on an 8x8 board similar to that used in chess or checkers Each player chooses a color (black or white), and the objective of the game is to accummlate as many pieces of your own color as possible. How to plav The game starts in the following configuration: Players alternate turns, with black moving first. A move consists of placing a piece of your color on the board in such a way that it outflanksone or more of your opponent's pieces. Outflanking means creating a straight line of your opponent's pieces that are bordered on both ends by your pieces. This may be done horizontally, vertically, or diagonally. Outflanking your opponent's pieces flips them to your color. If a player cannot outflank any of his/her opponent's pieces during a turn, s/he ust forfeit that tum pass his/ber turn if any valid moves exist. Aplayer may not The game ends when neither player is able to make a valid move. (This is guaranteed to happen when the board is full, but it may occur before that. For example, if one player manages to flip all of his/ber opponent's pieces before the board is full, the opponent is left with no valid moves.) The winner is the player with the higher number of pieces on the board

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

Step: 3

blur-text-image

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 Publishing With Filemaker Pro On The Web

Authors: Maria Langer

1st Edition

0201696657, 978-0201696653

More Books

Students also viewed these Databases questions