Beetle Game

Assignment:

Structure Chart:

Constructor
Set Person1Score to 0
Set Person2Score to 0
Set turn = 1;
Call Instructions();

Repeat while (Person1Score  is not 6 and Person2Score is not 6)
     if turn is 1
         Print “It is person 1’s turn”
         Person1Score = Turn (Person1Score)
         turn=2
     else if turn is 2
         Print “It is person 2’s turn”
         Person2Score = Turn (Person2Score)
         turn =1

if (Person1Score is 6)
    Print “Person 1 won”
else
    Print “Person 2 won” 

public void Instructions( )

//Pre: None
//Post: Everyone knows the instructions

Print this:
The goal of beetle is to be the first to draw the beetle in the correct order. 
In our game, we will draw a human instead.
To be able to draw a body part, you need to roll the correct thing at the correct time.
     Body = 1
     Head = 2
     Left Leg = 3
     Right Leg = 4
     Left Arm = 5
     Right Arm = 6
If you don’t roll what you are looking for, the part passes to the other player.

public int RollDice( )
//Pre: None
//Post: The dice is rolled and the number 1-6 is returned
Roll the dice (get a random number)
Pass back the number

public int Turn (int score)
//Pre: score is the player’s score between 0-6.
//Post: the player’s new score after their turn is returned
Call Roll Dice, save their answer in “Roll”.
If (Roll = = Score+1)
    Call Draw Beetle (Score +1)
    Return Score + 1
Else 
    Print Roll and write “Too bad”
    Return Score

public void DrawBeetle (int Score)
//Pre: score is the player’s score between 0-6.
//Post: the new beetle/human is drawn on the screen
Print “Your score is “+ Score
if score ==0
   Draw nothing
else if score == 1
   Draw backbone
else if score ==2
   Draw backbone and head
else if score == 3
   Draw backbone, head and left leg
else if score ==4 
   Draw backbone, head, both legs
else if score ==5
   Draw backbone, head, both legs and left arm
else
   Draw the entire picture