Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Rock paper scissors class design problem using JAVA. Below I posted what needs to be done(2 classes and 1 driver) PLEASE FOLLOW ALL THE DIRECTIONS.

Rock paper scissors class design problem using JAVA.

Below I posted what needs to be done(2 classes and 1 driver)

PLEASE FOLLOW ALL THE DIRECTIONS. NO ARRAYLIST, NO IMPORTS(ONLY SCANNER IS OKAY)

KEEP EVERYTHING AS SIMPLE AS YOU CAN. THIS IS AN INTRO TO COMPUTER SCIENCE CLASS

Class Design: Player The Player class is intended to be an abstract and simplified representation of someone playing a Rock, Paper, Scissors game.

Class Properties (MUST be private)

Name or nickname of player

Array storing the players choices for all rounds in a game Class Invariants

Player name must be at least three characters long.

Choices can only be Rock, Paper, or Scissors Class Components

Constructor that takes in as argument the players name (enforce invariants)

Public Getters for name and choices o Optional: Private Setter for name and choices

Public method that takes in a choice and stores it in the array of choices (enforce invariants)

Class Design: Game

The Game class is intended to be an abstract and simplified representation of a Rock, Paper, Scissors game. This object should keep track of players and outcomes for the game.

Class Properties (MUST be private)

First player

Second player Class Invariants

Players must have different names (otherwise ambiguous as to who the winner is)

Players must each have made at least one choice (at least one round played) Class Components

Constructor that takes in as arguments two players (enforce invariants)

NO public getters or setters (private getters/setters acceptable)

Public method that returns the name of the winner of the round

o You will need to compare the choices that the players have made and determine who the winner is assume best 2 out of 3 rule

If a player only made two choices and won those two choices, they won regardless of how many choices the other player made

If both players only played enough rounds to end in a tie, you must determine what to return in the case of a tie

If a player did not make enough choices to win, that player is considered to have forfeit the game and the other player wins. Examples: Player 1 Rock Rock Paper Player 2 Scissors Paper Paper Rock

This results in Player 2 winning because it was a tie when Player 1 gave up. Player 1 Rock Rock Scissors Player 2 Scissors Paper Paper Rock

This results in Player 2 winning because Player 1 is presumed to have given up before the round concludes (even though Player 1 was winning by the third choice).

Driver Class: GameDriver

The GameDriver class is intended to be a simple driver to test the Game object:

Create two players (e.g. player 1 and player 2)

Add some choices to each player such that player 1 wins

Create a Game

Print out the winner of the game

Create another game that results in a tie

GRADING CRITERIA:

Player class object (Total: 12 points)

o [1 point] Proper Class definition syntax

o [2 points] Implements all required properties

o [1 points] Implements required getters

o [1 points] Name invariant properly enforced

o [3 points] Choice invariant properly enforced

o [2 points] Constructor properly implemented

o [2 points] add choice method properly implemented

Game class object (Total: 16 points)

o [1 point] Proper Class definition syntax

o [2 points] Implements all required properties

o [3 points] All invariants properly enforced

o [2 points] Constructor properly implemented

o Method to determine winner works correctly to determine

[3 points] Player 1 wins

[3 points] Player 2 wins

[2 points] Tie GameDriver driver class (Total: 12 points)

o [1 point] Proper Class definition syntax

o [1 point] Proper main method syntax

o [3 points] Created two players

o [2 points] Created a game

o [2 points] Print out the winner of the game

o [3 points] Created another game that results in a tie

Extra Credit [2 points] for proper creation/usage of an enum for choices

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

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

=+ Understand workplace aggression.

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago