Nencetty_K_Mod5_Pseudocode

docx

School

Southern New Hampshire University *

*We aren’t endorsed by this school

Course

3120 IT312

Subject

Computer Science

Date

Feb 20, 2024

Type

docx

Pages

8

Uploaded by BaronFog20240

Report
Kylie Nencetty IT 312 Module 5-1: Pseudocode 2/11/2024 LiarsDice.cpp: START Void Function displayRules() GET file LiarsDiceRules.txt DISPLAY rules to user Int Function Main() Seed random number generator DECLARE int variable for numberOfPlayers OUTPUT title of game to user CALL displayRules() OUTPUT request for user to input number of players IF user input is less than 2 players OUTPUT message to user stating at least 2 players are needed to play OUTPUT request for user to input number of players again ELSE set and store number of players input by the user as numberOfPlayers ENDIF SET MainGame class object game CALL givePlayerDice() function CALL playerName() function
Player.h CLASS Player DECLARE string variable for player’s name DECLARE int variable for player token DELARE Player constructor SET Player with string for playersName Void Function setName() String Function getName() Void Function setScore() Int Function getScore() Dice.h CLASS Dice SET an array for player’s dice with 5 ints Void Function diceRoll() Increment if value is less than 5 CALL random number generator to set an array of player’s dice with 5 random numbers between 1 and 6 Void Function revealDice() Increment if value is less than 5 OUTPUT the value of the player’s dice. Void Function revealAllDice()
Increment if value is less than number of dice rolled OUTPUT the value of the of all the dice MainGameloop.h CLASS MainGame DECLARE player class pointer DECLARE int variable for the active player, activePlayer DECLARE int variable to keep track of the number of players, currentPlayers DECLARE dice class variable dice DECLARE MainGame constructor as an int SET using numberOfPlayers Void Function to display the player’s name Void Function to give each player dice Void Function to start the game Void Function to place a guess Boolean Function for the winner of the round Void Function to start each subsequent round Void Function for active player’s round results Player.cpp CLASS player constructor
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
SET name to the user input SET pointer to 0 CLASS player constructor String for playersName SET name to player class pointer Void Function setName() SET playersName equal to player class pointer for name String function getName() RETURN name of player Void Function setScore() SET token equal to player class pointer of token Int Function getScore() RETURN token MainGameLoop.cpp CALL MainGame constructor using int numberOfPlayers as parameter SET an array for player class using numberOfPlayers SET int variable currentPlayers to equal numberOfPlayers CALL void function to display player’s name SET string variable for name FOR loop that runs while iterator is less than currentPlayers, iterator should increment each loop
OUTPUT request to enter user’s name Store input as name Call setName function to store name in the player array ENDFOR CALL void function givePlayerDice FOR loop that runs while iterator is les than currentPlayers, iterator should increment each loop CALL diceRoll() function ENDFOR CALL void function for the player to place guess DECLARE int variable guessNumberOfDice DECLARE int variable guessDiceSide DECLARE int variable placedGuess OUTPUT request for user to input guess for dice side STORE input as guessDiceSide OUTPUT a request for user to input a guess of the number of dice with that side STORE input as guessNumberOfDice SET placedGuess equal to guessNumberOfDice OUTPUT that player’s turn is over OUTPUT the start of next player’s turn DECLARE int variable callLiar DECLARE int variable actualNumberOfDice and INITIALIZE to 0 DECLARE int variable tokenWon and INITIALIZE to 0
FOR loop that runs while iterator is less than the number of players in the array OUTPUT request for current user to enter ‘1’ or ‘2’ accept previous guess call out or call the player a liar. STORE input as callLiar IF callLiar equals ‘1’ OUTPUT that the previous guess has been accepted SET tokenWon to activePlayer SET the value of player array to tokenWon OUTPUT request for active player to input a guess for dice side STORE input as guessDiceSide OUTPUT request for active player to input a guess of the number of dice with that side STORE input as guessNumberOfDice IF guessNumberOfDice is less than or equal to placedGuess OUTPUT request for user to enter a number that is higher than previous guess STORE input as guessNumberOfDice ENDIF SET placedGuess equal to guessNumberOfDice Increment activePlayer ELSEIF callLiar equals “2” OUTPUT that the previous player has been called a liar CALL revealAllDice() function
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
ENDIF IF revealAllDice equals guessDiceSide Increment/SET actualNumberOfDice ENDIF IF actualNumberOfDice is greater than or equal to guessNumberOfDice OUTPUT that player guessed correctly, and is not a liar OUTPUT activePlayer has won the round SET tokenWon to 1 SET tokenWon to activePlayer in the player array ELSE OUTPUT that the player is a liar OUTPUT which player in the array has won SET tokenWon to 1 SET tokenWon to whichever player in the array called out the liar ENDIFELSE IF tokenWon equals 1 EXIT ENDIF ENDFOR CALL Boolean Function for round winner FOR loop that runs while iterator is less than currentPlayers, iterator should increment each loop IF the number of players in the array equals 1 or the activePlayer has a player
array value of 1 SET index pointer equal to iterator RETURN true ENDIF ENDFOR RETURN false CALL Void Function for active player’s round results SET activePlayer equal to iterator OUTPUT the active player’s name and that they have rolled CALL revealDice function CALL placedGuess CALL Void Function for to start the subsequent round FOR loop that runs while iterator is less than currentPlayers, iterator should increment each loop CALL function for active player’s round results using iterator as parameter ENDFOR CALL Void Function to start the game WHILE the Boolean Function for a winner is false CALL the function to start the subsequent round ENDWHILE