Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project Description The goal of this project is to test your ability to use the knowledge of Java that you have obtained in the course.

Project Description

The goal of this project is to test your ability to use the knowledge of Java that you have obtained in the course. The focus of this project is to use Graphical User Interface (GUI) together with object-oriented programming. The goal is to create a tic-tac-toe game based on a well-designed interface. The user will be playing against a computer opponent that will pick an open spot on the board.

It is worth noting that you should respect the following decomposition of classes and methods together with their appropriate graphical user interface. Any project doesn`t follow the below decomposition of classes/methods will be rejected.

Program Functionality

1.1 Program Steps

Display the current board state (Graphical User Interface).

Choose a position on the board for the users move.

a) If the user enters a position that already has an X or an O, then tell the user that the position is occcupied.

Start over from step 2.

b) If the user enters a valid, unoccupied position, this should be considered the users move.

Display the board, now updated with the players move

If the users move results in a win, tell the user that she has won.

Terminate the program.

iii. If the users move results in a tie (cat), tell the user that the game has ended in a tie (cat).

Terminate the program. iv. The computer opponent should then randomly choose an open spot on the board.

Display the board, now updated with the computers move

If the computers move results in a win, tell the user that the computer has won.

Terminate the program.

1.2 Details

The board should be represented by an array of buttons.

The computers moves should be completely random at the least. If you want to do more intellegent move making, you may recieve extra points.

In my example, the user goes first. If you want to randomly select which player goes first, this is also acceptable and will get you bonus points.

All the normal rules to tic-tac-toe apply to this game. If you do not know the rules of tic-tac-toe, or have a specific question on the rules, feel free to ask the instructor.

Possible Object Design

Board - An object representing a tic-tac-toe board Attributes

gameBoard An array of buttons representing the board

Methods

i. Constructors

Board() - Initializes the board to an empty board

Board(JButton [] inBoard) - Initializes the board to inBoard

ii. Accessors

boolean submitMove(String move, char player) - adds the move to the board, and returns true if the space specified in the move is not taken. If the space is taken, do not add the move and return false.

boolean isWinner(char player) - Returns true if the player whose marker is passed as a parameter has won the game, false otherwise.

boolean isCat() - Returns true if there is a CAT(tie), false otherwise.

boolean isMoveValid(String move) - Returns true if the parameter is a move on the board, otherwise it returns false

Player An object representing a player of the tic-tac-toe game Attributes

char marker - Character representing whether this player is using X or O as her marker

boolean isHuman - Boolean indicating if the player is a human player or a computer player

Methods

i. Constructors

Player() - Initializes the marker to X and isHuman to true

Player(boolean inIsHuman) - Initializes isHuman to inIsHuman and if inIsHuman is true, marker to X, otherwise marker to O

Player(boolean inIsHuman, char inMarker) - Initializes isHuman to inIsHuman and marker to X if inMarker is X or x, otherwise marker to

O

ii. Accessors

char getMarker() - Returns the players marker

boolean getIsHuman() - Returns whether the player is human or not

String getPlayerMove() - Returns the move from the player (either from human or computer).

String getHumanMove() - Prompts the user for a move, retreieves input from the keyboard, and returns it.

String generateComputerMove() - Returns a move randomly generated.

Concluding Remarks

You may use your own design of objects for this project, but you are required to write at least two classes as well as a graphical user interface, and your program should follow objectoriented programming principles. Bonus points will be given if you allow the option for two computer players to play each other, two human players to play each other, a human going first against a computer player, or a human going second against a computer player.

Your program should be easy to use and understand. I highly suggest giving the user instructions when the program starts and gently reminding her when she inputs something invalid. You are required to have sufficient internal documentation for your program as discussed in class.

This is meant to be AN INDIVIDUAL ASSIGNMENT. Also, taking large segments of code from other sources without citing is plagiarism. The majority of this assignment should be

YOUR OWN ORIGINAL WORK. answer the question with details and write the main class and show me a picture of the run of this program

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

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago