Homework 1, Beetle .

Short Description:

Write a program that simulates players playing the game of Beetle

Goals

When you finish this homework, you should have:

Formal Description

The game Beetle is a parlor game which has been turned into the commercial game Cootie. For this homework you should implement an object-oriented version of Beetle.

Game Rules

Please note, I am using the Wikipedia page for these rules. You can find other versions in other places. The version described on this page is the version you should be implementing.

Beetle is played using a single die. On their turn a player repeatedly rolls the die, and collects a piece of a beetle if they can. When a player rolls a piece that they do not have the pre-requisite for, or have reached the limit of, their turn is over.

The goal is to be the first player to assemble a complete beetle.

For this game:
Roll Item Limit Rule
1Eye 2Must have a head.
2Antenna 2Must have a head.
3Leg 6Must have a body.
4Wing 2Must have a body.
5Head 1Must have a body.
6Body 1Must be the first part obtained.

Example

The first player rolls a 2, but they don't have a head so their turn ends.

The second player rolls a 6, and obtains a body, they then roll a 2, but they need a head for an antenna, so their turn ends.

The third player rolls a 6, and obtains a body, they then roll a 5 and obtain a head. On the next roll they roll another 6, but they have exceeded their body limit, so the turn ends.

At the end of the first round, the first player has no items, the second player has a body and the third player has a body and a head.

Implementation Details

Your game should start by asking for the number of players, 2-4. After this it should simulate a game of beetle for those players.

At the beginning of each round, you should print information about the state of each player. (See the example below)

As the round progresses, you should print detailed information about what is happening (See the example below)

The winner is the first player to complete a beetle, and the game ends instantly when this occurs.

Example output

Your output should follow this example fairly closely
Please enter the number of players (2-4) => 1
    I'm sorry, you should have between 2 and 4 players.
Please enter the number of players (2-4) => 3
    We will be playing with 3 players.

Round 1:
   Player 1: Body 0, Head 0, Wings: 0, Legs: 0, Antenna: 0 Eyes: 0
   Player 2: Body 0, Head 0, Wings: 0, Legs: 0, Antenna: 0 Eyes: 0
   Player 3: Body 0, Head 0, Wings: 0, Legs: 0, Antenna: 0 Eyes: 0

Player 1 rolls a 2: antenna, but they don't have a head so the turn ends.

Player 2 rolls a 6: body, a body is added.
Player 2 rolls a 2: antenna, but they don't have a head so the turn ends.

Player 3 rolls a 6: body, a body is added.
Player 3 rolls a 5: head, a head is added.
Player 3 rolls a 6: body, but don't need another body so the turn ends.

Round 2:
   Player 1: Body 0, Head 0, Wings: 0, Legs: 0, Antenna: 0 Eyes: 0
   Player 2: Body 1, Head 0, Wings: 0, Legs: 0, Antenna: 0 Eyes: 0
   Player 3: Body 1, Head 1, Wings: 0, Legs: 0, Antenna: 0 Eyes: 0

...
Round 7:
   Player 1: Body 1, Head 1, Wings: 1, Legs: 6, Antenna: 2 Eyes: 2
   Player 2: Body 1, Head 1, Wings: 1, Legs: 6, Antenna: 2 Eyes: 2
   Player 3: Body 1, Head 1, Wings: 2, Legs: 4, Antenna: 2 Eyes: 2

Player 1 rolls a 1: wing, a wing is added.
Player 1 completes their beetle, they win.

Further details

Attribute

I used ChatGPT to review the assignment. It definitely cleaned up the problem, but I deliberately did not remove some of the ambiguity from my original statement. If you have a question about the assignment, and you probably should, you should ask in class well before the assignment is due.

ChatGPT said:

One thing I would not change

I like your choice of Beetle.

It is actually a pretty good first object-oriented programming problem because the domain naturally contains objects and relationships:

Game →Players → Beetles → Parts

and it has enough state and rules to prevent students from writing a trivial "class with three getters and setters" exercise.

The biggest opportunity is to make the object responsibilities more explicit. Right now the assignment tells them what the program must do very well, but gives them somewhat less guidance about what should belong in which object. ...

Required Files

You should submit a single tar or zip file containing all files required to build your project. This includes

Submission

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