Your assignment is to complete the prototype that uses character-based graphics.
If you execute this Windows program or this Mac program or this Linux program, you will see the player (indicated by @) in a rectangular arena filled with vampires (usually indicated by V). At each turn, the user will select an action for the player to take: either move one step or drop a poisoned blood vial without moving. The player will take the action, and then each vampire will move one step in a random direction. If a vampire moves onto the grid point occupied by the player, the player dies from the vampire's bite. (If the player moves to a grid point occupied by a vampire, the player is bitten and dies, so that would be a dumb move.)
If a vampire lands on a grid point with a poisoned blood vial, it drinks all the blood in the vial. The first time a vampire drinks a vial of poisoned blood, it slows down: it doesn't move on its next turn, but it moves on the turn after that, then on the next turn it doesn't move, then it moves on the turn after that, etc., moving only every other turn. The second time a vampire drinks a vial of poisoned blood, it dies and turns to dust. (If a poisoned vampire moves to a grid point with both the player and a vial of poisoned blood, it drinks the blood in the vial and just before it dies, it bites the player, so both die.)
This smaller Windows version or Mac version or Linux version of the game may help you see the operation of the game more clearly.
At each turn the player may take one of these actions:
The game allows the user to select the player's action: n/e/s/w for movement, or x for dropping a poisoned blood vial. The user may also just hit enter to have the computer select the player's move.
After the player moves, it's the vampires' turn. Each vampire has an opportunity to move. A vampire that has previously drunk a vial of poisoned blood will not move if it attempted to move on the previous turn. Otherwise, it will pick a random direction (north, east, south, west) with equal probability. The vampire moves one step in that direction if it can; if the vampire attempts to move off the grid, however, it does not move (but this still counts as a poisoned vampire's attempt to move, so it won't move on the next turn). More than one vampire may occupy the same grid point; in that case, instead of V, the display will show a digit character indicating the number of vampires at that point (where 9 indicates 9 or more).
If after a vampire moves, it occupies the same grid point as the player (whether or not there's a vial of poisoned blood at that point), the player dies. If the vampire lands on a grid point with a poisoned blood vial on it, it drinks all the blood in the vial (and the vial is no longer part of the game). If this is the second vial of poisoned blood the vampire has drunk, it dies. If more than one vampire lands on a spot that started the turn with a poisoned blood vial on it, only one of them drinks the vial of poisoned blood.
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, Vampire, and Player. Details of the interface to these classes are in the program skeleton, but here are the essential responsibilities of each class:
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 whose values may change during execution (so global constants are OK). 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 vampire outside the arena.) If a function has a reasonable way of indicating failure through its return value, it 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:
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of