Homework 1, Beetle.

Short Description:

Write a program that will simulate a two player game of beetle.

Goals

When you finish this homework, you should have:

Formal Description

We will work on this game in class for the first few classes. I expect you to use that design and that code.

The game of beetle is a simple die game for children. I am using the rules found here.

A random player begins the game by rolling the die. Using the below reference, the player will then draw the body part correlated to the number they rolled. The next player will then roll the die and draw their body part.
  1. Body
  2. Head
  3. A leg
  4. An eye
  5. An antenna
  6. The tail

You'll be sure to encounter a few challenges as you sketch your beetle. A body must be drawn before any other parts. A beetle without a body cannot have legs or a tail, after all! Furthermore, the head must be drawn before the eye and antenna can be added. Rolling a 1 and 2 is essential to completing your drawing. If you roll a number associated with a body part that cannot be drawn, your turn is skipped and the next player rolls. The first player with a fully sketched beetle is the winner!
Ha$bro sells a version of this game called Cootie.

We are going to write a simulation of this game.

Initially we will develop the game as written, but eventually we will want to expand this game to include bugs with more/different parts. In addition we will develop this game for two players, but we may expand that in the future as well.

The Die Class

I have written a die class that we will use in this game. This may be overkill, but it provides a unique functionality. It has the ability to store the rolls for a session, then re roll exactly the same way. I am going to try to focus on games this semester and such a class is a requirement in my world.

The die class has the following interface:

A typical installation of a die might be:
#include "Die.h"
...
int main() {
    // pick one of these
    // This one is for recording the game.
    DieDynamic die;
    die.Record("Afile.dice");
    // This one is for replaying the game
    // DieStatic die("Afile.dice");
    ...  

Note, you can't copy the die, and it must be passed by reference. A function that uses the die might be:

void RollDie(Die & theDie){
    int roll{theDie.Roll()};

    cout << "You roll a " << roll << endl;
    roll = theDie.Roll();
    cout << "The second roll is " << roll << endl;
} 
This restriction is somewhat strange, but the die has an internal state AND we are able to pass any type of die in that we want. We will discuss this further when we get to chapter 10.

We will discuss UML diagrams this semester. Here is the one for the die class.

Your output should match the output in AGame.txt provided below. Briefly:

Provided Files

Notes

Required Files

A single tar or zip file containing the source code and makefile for this program.

Submission

Submit the assignment to the D2L folder Homework 1 by the due date.