Question: C++ code only Overview We're going to revisit the robot code from the 'functions' lab and turn the code into a class called 'Robot'. We're

C++ code only

Overview

We're going to revisit the robot code from the 'functions' lab and turn the code into a class called 'Robot'. We're then going to make a multiplayer game where players race to build their robots. This will use a vector of robot objects.

You will use the RobotController class to managed both the game, players and Robots.

You need to complete the RobotController and Robot classes based onthe code I provide in a later slide.

Robot class

Using the rules from the previous robot (repeated on the next slide), make a robot with the following methods to the Robot class

Robot(); // Constructor that initializes the robot to 'empty' bool addPart(); // Part will be 'Leg' or 'Hand', etc. Gives the Robot that part only // if the rules allow it (This is where the logic resides) return true // if the part was added, false otherwise int countPart(); // Returns the number of parts of that type added bool complete(); // Returns true if the robot is complete or false if not void print(); // Prints the robot part counts in a single neatly formatted line void setName(string name); // Set the 'name' of the player using that robot string getName(); // Returns the name of the Robot

Robot parts table

If the dice roll is,

you may add this part

if you already have this number of parts

and no more than this amount.

1

Foot

Any. You can always add a Foot

2

2

Leg

A free Foot. If the number of Feet is more than the number of Legs, you can add a Leg

2

3

Torso

2 Legs

1

4

Arm

Torso

2

5

Hand

A free Arm. If the number of Arms is more than the number of Hands, you can add a Hand.

2

6

Head

Torso

1

7

Antenna

Head

1

8

Laser

Hand

1

RobotController class

This class maintains the vector and runs the game. If requires the following methods:

void initializeGame(int numPlayers);

void playGame();

These are described in the template code I've provided on a later slide.

Getting started with a template

Since we're using a variety of operating systems, we're just going to put all the code into one file. Real world programming would have many files for this lab, as we cover in the next course CSC125

Here's a template .cpp file for you to use. Click on main.cpp

http://www.csit.parkland.edu/~kurban/permanent/cpp-examples/robot/

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!