Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will create a GamePiece class, to be used in a variation of the classic Rock, Paper, Scissors game. This variation is called Rock, Paper,

You will create a GamePiece class, to be used in a variation of the classic Rock, Paper, Scissors game. This variation is called Rock, Paper, Scissors, Lizard, Spock.

image text in transcribedimage text in transcribed

Can someone help me out with this?

The GamePiece class will contain the following fields: classification The classification of the game piece Valid values are based on an enumerated type, Piece o o Rock - Paper - Scissors Lizard Spock name o The String value of th o "Rock", "Paper", "Scissors", "Lizard", or "Spock" are the valid values. e name, corresponding to the enumerated ty pe playerName o The name of the person playing (of type String) o Can be any name under 20 characters long The class will contain the following methods: GamePiece() o Constructor-inilizes the fields to their default values - Default classification is set to Rock - Default name is set to "Rock GamePiece (Piece classification, String name, String playerName) o Constructor- initialize the fields to the values passed in by the client Getter and setter methods for each of the field names toString) overridden from the Object class This method should return a string containing a reference to the value in the following, depending on the internal Piece value o o Rock: "I'm hard and have sharp edges." -Paper: "I'm made of trees and can cover a rock easily. and disprove Spock!" Scissors: "I'm extra sharp to cut right through paper.. and lizards!" Lizard: "Hsssss." Spock: "It is only logical that you do your CIS 2353 homework." equals o overridden from the Object class o A GamePiece is "equal" to another GamePiece if their classifications match .compareTo(GamePiece otherPiece) o o o implemented from the interface Comparable Specifically, Comparable should be used for the interface The method returns the following 1 is the current game piece object's classification is less than otherPiece' s classification O if the game pieces have the same classification 1 if the current game piece object's classification is greater than otherPiece' s classification

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

More Books

Students also viewed these Databases questions