Kategoriak: All - game - design - choice - class

arabera Gary Sibbitts 10 years ago

313

Class Design

Creating a Rock-Paper-Scissors (RPS) game involves designing a class with a constructor to initialize the game object appropriately. The constructor can be a placeholder initially, with no data or object associated yet.

Class Design

Constructor

need to be able to create our RPS object, the question is when and how?

and then what?

get the game result
get the computer's choice

when needed

1) user has indicated they want to play


the first time user makes a choice

implies user may play rps multiple times and wants to reuse the object


gameResult = rps.Play(userChoice, out computerChoice); computerChoice = rps.computerChoice;
rps.userChoice = userChoice;
user makes a choice
RockPaperScissors(RPSChoice userChoice)
user wants to play

Just declare it

just a place holder, no data or object yet

At the beginning?

we haven't done anything yet and it doesn't really know anything either

Default constructor
At program/form initialization

Class Design

RPS