Program that use classes game-arena-robot and player

Assignment Help C/C++ Programming
Reference no: EM13762817

Rage Against the Machines

Your assignment is to complete this C++ program skeleton to produce a program that implements the described behavior. (We've indicated where you have work to do by comments containing the text TODO; remove those comments as you finish each thing you have to do.) The program skeleton you are to flesh out defines four classes that represent the four kinds of objects this program works with: Game, Arena, Robot, and Player. Details of the interface to these classes are in the program skeleton, but here are the essential responsibilities of each class:

Game

To create a Game, you specify a number of rows and columns and the number of robots to start with. The Game object creates an appropriately sized Arena and populates it with the Player and the Robots.
A game may be played.

Arena
When an Arena object of a particular size is created, it has no robots or player. In the Arena coordinate system, row 1, column 1 is the upper-left-most position that can be occupied by a Robot or Player. (If an Arena were created with 10 rows and 20 columns, then the lower-right-most position that could be occupied would be row 10, column 20.)
You may tell the Arena object to create or destroy a Robot at a particular position.
You may tell the Arena object to create a Player at a particular position.
You may tell the Arena object to have all the robots in it make their move.
You may ask the Arena object its size, how many robots are at a particular position, and how many robots altogether are in the Arena.
You may ask the Arena object for access to its player.
An Arena object may be displayed on the screen, showing the locations of the robots and player, along with other status information.

Player
A Player is created at some position (using the Arena coordinate system, where row 1, column 1 is the upper-left-most position, etc.).
You may tell a Player to stand, move in a direction, or shoot in a direction.
You may tell a Player to take an action of its choice.
You may tell a Player it has died.
You may ask a Player for its position, alive/dead status, and age. (The age is the count of how many turns the player has survived.)
Robot
A robot is created at some position (using the Arena coordinate system, where row 1, column 1 is the upper-left-most position, etc.).
You may tell a Robot to move.
You may ask a Robot object for its position.

The skeleton program you are to complete has all of the class definitions and implementations in one source file, which is awkward. Since we haven't yet learned about separate compilation, we'll have to live with it.

Complete the implementation in accordance with the description of the game. You are allowed to make whatever changes you want to the private parts of the classes: You may add or remove private data members or private member functions, or change their types. You must not make any deletions, additions, or changes to the public interface of any of these classes - we're depending on them staying the same so that we can test your programs. You can, of course, make changes to the implementations of public member functions, since the callers of the function wouldn't have to change any of the code they write to call the function. You must not declare any public data members, nor use any global variables other than the global constants already in the skeleton code, except that you may add additional global constants if you wish. You may add additional functions that are not members of any class. The word friend must not appear in your program.

Any member functions you implement must never put an object into an invalid state, one that will cause a problem later on. (For example, bad things could come from placing a robot outside the arena.) Any function that has a reasonable way of indicating failure through its return value should do so. Constructors pose a special difficulty because they can't return a value. If a constructor can't do its job, we have it write an error message and exit the program with failure by calling exit(1);. (We haven't learned about throwing an exception to signal constructor failure.)

What you will turn in for this assignment is a zip file containing this one file and nothing more:

A text file named robots.cpp that contains the source code for the completed C++ program. This program must build successfully, and its correctness must not depend on undefined program behavior. Your program must not leak memory: Any object dynamically allocated during the execution of your program must be deleted (once only, of course) by the time your main routine returns normally.

Reference no: EM13762817

Questions Cloud

Indifferent between accepting the project and rejecting : A project that provides annual cash flows of $28,500 for nine years costs $138,000 today. If the required return is 8 percent, the NPV for the project is $_____ . If the required return is 20 percent, the NPV is $______. At a discount rate of ___perc..
Shawshank redemption : The name of the movie is ShawShank Redemption. Please look at the movie and find 3 people who have started enterprise like business, services and one more enterprise person.
Create an order application : Create an Order application that prompts the employee for the number of burgers, fries, and sodas and then display the total, the tax (6.5%), and the final cost.
Duties in an actual crime scene : What materials will you use to lift these molds from the ground.
Program that use classes game-arena-robot and player : Your assignment is to complete this C++ program skeleton to produce a program that implements the described behavior. (We've indicated where you have work to do by comments containing the text TODO;
Provide a physical design that will meet the specifications : System design will include visual presentations of each of the following: modeling for specifications, data design, and user interface design. Each of the diagrams will visually represent your design - Provide a physical design that will meet the s..
Modify the inventory program to include an add button : Modify the Inventory Program to include an add button, a delete button, and a modify button on the GUI. These buttons should allow the user to perform the corresponding actions on the item name, the number of units in stock, and the price of each ..
Journal entry to record depreciation expense-robillard inc : (a) Prepare the journal entry to record depreciation expense for the equipment in 2012. (b) Prepare the journal entry to record depreciation expense for the building in 2012.
Issues based on world health organization who : How do the causes of death in that country deteriorate one's health?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Refresher on andys basic requirements

The game Battleship is back and better than ever. Instead of hacking everything together in C, you will instead leverage C++ and all of your newly gained object oriented programming knowledge to construct a much cleaner end product.

  When given a c-string reference and a character

Write a program that implements and tests the following functions for use with C-strings (you may assume that  input obtained by the program is limited to a maximum of 80 characters):

  Program to play lottery

The program randomly generates a Lottery of a three-digit number ( any number from 100 to 999), prompts the user to enter a three-digit number, and determines whether the user wins according to the subsequent rule:

  Write a program that plays a tic-tac-toe game.

Using functional decomposition, write a program that plays a tic-tac-toe game.

  Write a program to check whether a number is even or odd

Write a C++ program to check whether a number entered by user is even or odd.

  Perimeter of a trapezoid

Write a function in c that will return the perimeter of a trapezoid

  Multidimensional arrays

multidimensional arrays to life, let's consider a specific example: How can you visualize a 4-dimensional array? How can you give meaning to each dimension this array has? What kind of application would such an array be useful for?

  How do you generate arrays, random numbers

How do you generate arrays, random numbers and multiply and add rows, columns and diagonals in C

  Compute the sum of the integers

Write a short code fragment that would compute the sum of the integers from 1 to 100 and leave this sum in $6. No input or output is necessary.

  Improvemented program

What does this program do and would you improve it?

  Define a string of four characters and converts

Write an assembly program that defines a string of four characters and converts it into an unsigned 16-bit integer.

  Implement a second-order low-pass filter

Implement a second-order low-pass filter using the finite difference method. The finite difference method is a useful mathematical method that is used to numerically solve differential equations.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd