On java, and easy simple
Posted: Fri May 20, 2022 11:26 am
On java, and easy simple
Design of Rock-Paper-Scissors Play game start start Print instructions Read and validate user choice Generate computer's choice Play game Determine winner Ask user If(s)he wants to play again Print winner Y N Play again? Print stats: wins, losses and ties end Update stats end
Read and validate user choice Generate computer choice start start Prompt user to enter choice Read user choice from keyboard Generate a random number between and 2. where 0 corresponds to ROCK, 1 corresponds to PAPER, and 2 corresponds to SCISSORS. N Y User choice is rock, paper or scissors? end end
Determine winner Update stats start start User choice is same as computer choice? User choice is ROCK and computer choice is SCISSORS OR User choice is ŞCISSORS and computer choice is PAPER N OR User choice is PAPER and computer choice is ROCK Result is tie? Result is win for user? N Y N Result is tie Result is: win for user Result is: loss for user ties++ wins++ losses++ end end
Methods (subtasks) Methods (continued) Needs Returns . printinstructions None None Print instructions Play game - readAndValidateUserChoice -generateComputerChoice - determine Winner - updateStats readAndValidateUserChoice None Validated user choice generate Comp Choice None Computer choice determine Winner Result of game User choice and computer choice Result of game updateStats None (updates wins/losses/ties)
Methods (updated) Needs Retums getinstructions None String readAndValidateUserChoice None Validated user choice generate CompChoice None Computer choice determine Winner User choice Result of game and computer choice Current stats, Updated stats result of game (wins/losses/ties) updateStats
Design of Rock-Paper-Scissors Play game start start Print instructions Read and validate user choice Generate computer's choice Play game Determine winner Ask user If(s)he wants to play again Print winner Y N Play again? Print stats: wins, losses and ties end Update stats end
Read and validate user choice Generate computer choice start start Prompt user to enter choice Read user choice from keyboard Generate a random number between and 2. where 0 corresponds to ROCK, 1 corresponds to PAPER, and 2 corresponds to SCISSORS. N Y User choice is rock, paper or scissors? end end
Determine winner Update stats start start User choice is same as computer choice? User choice is ROCK and computer choice is SCISSORS OR User choice is ŞCISSORS and computer choice is PAPER N OR User choice is PAPER and computer choice is ROCK Result is tie? Result is win for user? N Y N Result is tie Result is: win for user Result is: loss for user ties++ wins++ losses++ end end
Methods (subtasks) Methods (continued) Needs Returns . printinstructions None None Print instructions Play game - readAndValidateUserChoice -generateComputerChoice - determine Winner - updateStats readAndValidateUserChoice None Validated user choice generate Comp Choice None Computer choice determine Winner Result of game User choice and computer choice Result of game updateStats None (updates wins/losses/ties)
Methods (updated) Needs Retums getinstructions None String readAndValidateUserChoice None Validated user choice generate CompChoice None Computer choice determine Winner User choice Result of game and computer choice Current stats, Updated stats result of game (wins/losses/ties) updateStats