CSCI 235 Spring 2024 Term Project
Algorithmic Adventures II: Exponential Creature Odyssey
Now that we have our full-fledged Creatures and a game world, let's implement some game functionality. In this project you will modify the classes you have implemented thus far to allow Creatures to be fed – after all, a hungry Creature is an angry Creature, and one does not want to be in a Cavern with angry Creatures. Conveniently, the Cavern seems to be home to a variety of fungi, from which Selfa Ensert has managed to create MycoMorsel
, a food derived from fungus. This might be a cost-effective, albeit a dubious form of sustenance to the Creatures, but eating MycoMorsels will most likely affect each Creature
subclass and types differently. Have your Dragons
, Ghouls
, and Mindflayers
feast in the Cavern
by eating MycoMorsel and see what happens to them!
The link to accept the GitHub Classroom assignment can be found on Blackboard
This project consists of two parts:
You will modify the Creature
class and its subclasses to enable them to eat MycoMorsel and display their current status.
You will modify the Cavern
to store Creature
subclasses polymorphically and access each subclass-specific MycoMorsel actions.
Abstract Classes and Polymorphism:
Reading from input file:
String manipulation:
Dynamic memory allocation:
Work through the tasks sequentially (implement and test). Only move on to a task when you are positive that the previous one has been completed correctly. Remember that the names of classes and methods must exactly match those in this specification (FUNCTION NAMES, PARAMETER TYPES, RETURNS, PRE AND POST CONDITIONS MUST MATCH EXACTLY).
Remember, you must thoroughly document your code!!!
Creature
class and its Subclasses
Make the display()
function pure virtual
Add the following public member function and also make it pure virtual
/**
@post : Modifies the creature's private member variables (the exact modifications will be subclass specific)
@return : true if the creature leaves the Cavern, false otherwise
*/
eatMycoMorsel
Add the following public member functions
x/**
@post : displays Dragon data in the form:
"DRAGON - [NAME]\n
CATEGORY: [CATEGORY]\n
HP: [HITPOINTS]\n
LVL: [LEVEL]\n
TAME: [TRUE/FALSE]\n
ELEMENT: [ELEMENT]\n
HEADS: [NUMBER OF HEADS]\n
IT [CAN/CANNOT] FLY\n"
Example:
DRAGON - JHIZARD
CATEGORY: ALIEN
HP: 7
LVL: 5
TAME: TRUE
ELEMENT: FIRE
HEADS: 3
IT CAN FLY
*/
display
/**
@post : If the creature is UNDEAD, it becomes tame if not already, as it appreciates the gesture, even though as an UNDEAD it does not really eat.
It gains 1 hitpoint from the mysterious powers it receives by wearing the mushroom as a hat. Nothing else happens.
If the creature is an ALIEN, it consumes the mushroom and gains 1 additional hitpoint. Nothing else happens.
If the creature is MYSTICAL, it consumes the mushroom and gains 1 additional hitpoint if it has FIRE or EARTH affinity (Either by cooking the mushroom first, or by being fungi-tolerant). Nothing else happens.
But if it is MYSTICAL and has WATER, AIR, or no affinity, if it only has 1 hitpoint left, it doesn't want to risk it and leaves the Cavern. If it has more than 1 hitpoint, it loses 1 hitpoint and becomes untamed if it was tame. Nothing else happens.
@return : true if the creature leaves the Cavern, false otherwise
*/
eatMycoMorsel
Add the following public member functions
xxxxxxxxxx
/**
@post : displays Ghoul data in the form:
GHOUL - [NAME]\n
CATEGORY: [CATEGORY]\n
HP: [HITPOINTS]\n
LVL: [LEVEL]\n
TAME: [TRUE/FALSE]\n
DECAY: [DECAY]\n
FACTION: [FACTION]\n
IT [CAN/CANNOT] TRANSFORM\n"
Example:
GHOUL - JHRAT
CATEGORY: MYSTICAL
HP: 4
LVL: 8
TAME: TRUE
DECAY: 3
FACTION: FLESHGORGER
IT CAN TRANSFORM
*/
display
/**
@post : If the creature is UNDEAD, it becomes tame if not already, as it appreciates the gesture, even though as an UNDEAD it does not really eat. It gains 1 hitpoint from the mysterious powers it receives by wearing the mushroom as a hat. Nothing else happens.
If the creature is of Faction FLESHGORGER, it becomes so offended by being offered a mushroom that it becomes untamed if it was tame. If it was already untamed, it leaves the Cavern. Nothing else happens.
If the creature was of Faction SHADOWSTALKER, if it was untame, it hides from the mushroom and nothing happens. If it was tame, it eats the mushroom and loses 1 hitpoint, unless it only had 1 hitpoint left in which case it stays at 1 hitpoint but becomes untame. Nothing else happens.
@return : true if the creature leaves the Cavern, false otherwise
*/
eatMycoMorsel
Add the following public member functions
xxxxxxxxxx
/**
@post : displays Mindflayer data in the form:
"MINDFLAYER - [NAME]\n
CATEGORY: [CATEGORY]\n
HP: [HITPOINTS]\n
LVL: [LEVEL]\n
TAME: [TRUE/FALSE]\n
SUMMONING: [SUMMONING]\n
[PROJECTILE TYPE 1]: [QUANTITY 1]\n
[PROJECTILE TYPE 2]: [QUANTITY 2]\n
AFFINITIES: \n
[AFFINITY 1]\n
[AFFINITY 2]\n"
NOTE: For the Projectiles, print out the type and quantity of each projectile in the format:
[TYPE]: [QUANTITY] for each projectile in the vector, where the type is the string equivalent of the Variant (eg. "PSIONIC"/"TELEPATHIC"/"ILLUSIONARY"). If there are no projectiles, don't print anything.
For the Affinities, print out each affinity in the format: [AFFINITY 1]\n[AFFINITY 2]\n for each Affinity in the vector, where the Affinity is the string equivalent of the Variant (eg. "PSIONIC"/"TELEPATHIC"/"ILLUSIONARY"). If there are no affinities, don't print anything, including the label "AFFINITIES:".
Example:
MINDFLAYER - JHOCTOPUS
CATEGORY: UNDEAD
HP: 3
LVL: 6
TAME: TRUE
SUMMONING: TRUE
PSIONIC: 2
TELEPATHIC: 11
AFFINITIES:
PSIONIC
ILLUSIONARY
*/
display
/**
@post:
If the creature is UNDEAD, it becomes tame if not already, as it appreciates the gesture, even though as an UNDEAD it does not really eat. It gains 1 hitpoint from the mysterious powers it receives by wearing the mushroom as a hat. Nothing else happens.
If the creature is MYSTICAL, if it can summon a Thoughtspawn, it gives the mushroom to the Thoughtspawn instead. If it cannot summon a Thoughtspawn and is tame, it eats the mushroom to be polite. If it only had 1 hitpoint left, it remains at 1 hitpoint and becomes untame, else it loses 1 hitpoint. If it cannot summon a Thoughtspawn and is untame, it decides it doesn't have to deal with this and it leaves the Cavern. Nothing else happens.
If the creature is an ALIEN, if it has Telepathic affinity, it convinces Selfa Ensert to eat the mushroom instead, and gains 1 hitpoint from laughing at their resulting illness (as laughter is the best medicine).
If it is an ALIEN and does not have Telepathic affinity, but has a Telepathic projectile, it uses one of such projectile to achieve the same effect. (Remember to remove the projectile from the vector if it only had 1 left)
If it is an ALIEN and does not have Telepathic affinity or a Telepathic projectile, it eats the mushroom and gains 2 hitpoints. As it turns out, the mushroom was good for it. It becomes tame if it was not already. Nothing else happens.
@return : true if the creature leaves the Cavern, false otherwise
*/
eatMycoMorsel
Cavern
class
Cavern
to now store pointers to Creatures
, rather than Creature objectsImplement a parameterized constructor
xxxxxxxxxx
/**
@param: the name of an input file (a string reference)
@pre: Formatting of the csv file is as follows (each numbered item appears separated by comma, only one value for each numbered item):
1. TYPE: An uppercase string [DRAGON, GHOUL, MINDFLAYER]
2. NAME: An uppercase string
3. CATEGORY: An uppercase string [ALIEN, MYSTICAL, UNDEAD]
4. HITPOINTS: A positive integer
5. LEVEL: A positive integer
6. TAME: 0 (False) or 1 (True)
7. ELEMENT/FACTION: Uppercase string or strings representing the ELEMENT (For Dragons), or FACTION (For Ghouls) of the creature. If the creature is of a different subclass, the value will be NONE
8. HEADS: A positive integer of the number of heads the Dragon has. If the creature is of a different subclass, the value will be 0
9. FLIGHT/TRANSFORM/SUMMONING: 0 (False) or 1 (True) representing if the creature can fly (Dragons), transform (Ghouls), or summon a Thoughtspawn (Mindflayers).
10. DECAY: A non-negative integer representing the level of decay of the Ghoul. If the creature is of a different subclass, the value will be 0
11. AFFINITIES: Only applicable to Mindflayers. Affinities are of the form [AFFINITY1];[AFFINITY2] where multiple affinities are separated by a semicolon. Th value may be NONE for a Mindflayer with no affinities, or creatures of other subclasses.
12. PROJECTILES: Only applicable to Mindflayers. PROJECTILES are of the form [PROJECTILE TYPE1]-[QUANTITY];[PROJECTILE TYPE 2]-[QUANTITY] where multiple types of projectiles are separated by a semicolon. The value may be NONE for a Mindflayer with no projectiles, or creatures of other subclasses.
*/
Add the following public member functions
xxxxxxxxxx
/**
@post: For every creature in the cavern, displays each creature's information
*/
displayCreatures
/**
@param: a string reference to a category
@post: For every creature in the cavern of the given category (only exact matches to the input string), displays each creature's information
*/
displayCategory
/**
@post: Every creature in the cavern eats a MycoMorsel.
*/
mycoMorselFeast
Although you will no longer submit your test file, you must continue to thoroughly and methodically test your code.
Start by stubbing all expected functions. Have all function declarations in the .hpp and stubs for all functions in the .cpp. When submitted as such, your program will compile, although you will fail all tests, since you have not implemented any functions yet. If your program compiles, you will have at least established that all functions have correct name, parameters and return-type.
What is a stub? A stub is a dummy implementation that always returns a single value for testing (or has an empty body, if void). Don’t forget to go back and implement the stub!!! If you put the word STUB in a comment, some editors will make it more visible.
Now you can start implementing and testing your project, ONE FUNCTION AT A TIME!
Write a main()
function to test your implementation. Choose the order in which you implement your methods so that you can test incrementally: i.e. implement constructors then accessor functions, then mutator functions.
For each class, test each function you implement with all edge cases before you move on to implement the next function. This includes all constructors.
Make sure you include all packages and libraries you use.
How to compile with your Makefile:
In terminal, in the same directory as your Makefile and your source files, use the following command
xxxxxxxxxx
make rebuild
This assumes you did not rename the Makefile
and that it is the only one in the current directory.
Correctness 80% (distributed across unit testing of your submission)
Documentation 15%
Style and Design 5% (proper naming, modularity, and organization)
Important: You must start working on the projects as soon as they are assigned to detect any problems with submitting your code and to address them with us well before the deadline so that we have time to get back to you before the deadline.
We will grade the following :
Creature.hpp
Creature.cpp
Dragon.hpp
Dragon.cpp
Ghoul.hpp
Ghoul.cpp
Mindflayer.hpp
Mindflayer.cpp
Cavern.hpp
Cavern.cpp
Although Gradescope allows multiple submissions, it is not a platform for testing and/or debugging and it should not be used for that. You MUST test and debug your program locally. To help you not rely too much on Gradescope for testing, we will only allow 5 submissions per day. Before submitting to Gradescope you MUST ensure that your program compiles using the provided Makefile
and runs correctly on the Linux machines in the labs at Hunter (see detailed instructions on how to upload, compile and run your files in the “Programming Guidelines” document). That is your baseline, if it runs correctly there it will run correctly on Gradescope, and if it does not, you will have the necessary feedback (compiler error messages, debugger or program output) to guide you in debugging, which you don’t have through Gradescope. “But it ran on my machine!” is not a valid argument for a submission that does not compile. Once you have done all the above you submit it to Gradescope.
This project is due on Thursday 3/21.
No late submissions will be accepted.
You must start working on the projects as soon as they are assigned to detect any problems and to address them with us well before the deadline so that we have time to get back to you before the deadline. There will be no extensions and no negotiation about project grades after the submission deadline.
Help is available via drop-in tutoring in Lab 1001B (see website for schedule). You will be able to get help if you start early and go to the lab early. We only have 3 UTAs in the lab, the days leading up to the due date will be crowded and you will not be able to get much help then.
Authors: Georgina Woo, Tiziana Ligorio