CSCI 235 Fall 2023 Term Project

Algorithmic Adventures II: The Exponential Creature Odyssey

Project 2 - Creature Types: Inheritance

 

inheritance

 

You will now define different types of Creatures. You will implement 3 new classes that derive from the Creature class but also have additional attributes and methods specific to their type:

The link to accept the GitHub Classroom assignment can be found on Blackboard


Some additional resources on Inheritance, enums and structs


Implementation

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!!!



Task 1: Subclasses

The Dragon class

booksbooks

 

 

Data Types

The Dragon class must define the following type defined publicly inside the class:

The Dragon class must have the following private member variables:

Constructors

 

Unique methods


The Ghoul class

booksbooks

 

Data Types

The Ghoul class must have the following type defined publicly inside the class:

 

The Ghoul class must have the following private member variables:

 

The Ghoul class must have the following public member functions:

Constructors

Unique Methods


The Mindflayer class

booksbooks

Data Types

The Mindflayer class must have the following types defined publicly inside the class:

 

The Mindflayer class must have the following private member variables:

 

Constructors

 

Unique Methods

Note: This class uses a struct type. Struct is just short for "structure" and it is a user-defined type, much like a class. It is not a full fledged class, however. We use it to bundle data items with no or very few functions (none in this case). When initializing a new projectile you may use Projectile as the data type. For example for int x, int is our primitive data type. If we want to make a projectile called p1 we would write Projectile p1.

To set the data members of the struct we use the dot operator. For example, if we want to set the type of the projectile we would write p1.type_ = PSIONIC. If we want to set the quantity of the projectile we would write p1.quantity_ = 5.

Similarly, to access the data members of the struct we use the dot operator. For example, if we want to access the type of the projectile we would write p1.type_. If we want to access the quantity of the projectile we would write p1.quantity_.

 


Task 2: Testing

 

To give you some feel and guide into testing, we have added a testing task to this project. To be clear, the task below is not a thorough test of your classes. You must test every function you implement with valid and invalid values, and make sure it behaves as specified. This is only intended to motivate you into building a methodical and incremental testing practice.

Write a testing program as described below and name the file test.cpp. Instantiate the following creature objects that derive from the Creature class. For each creature object, print out the creature's information - including private member variables that are unique to their subclass - using the appropriate getter functions in the format:

Format for Dragons:

Format for Ghouls:

Format for Mindflayers: 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:".

test.cpp

Testing

How to compile with your Makefile:
In terminal, in the same directory as your Makefile and your source files, use the following command

 

 

This assumes you did not rename the Makefile and that it is the only one in the current directory.

You must always implement and test your programs INCREMENTALLY!!! What does this mean? Implement and TEST one method at a time. For each class:

Grading Rubric

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.

There will be no negotiation about project grades after the submission deadline.


Submission:

We will grade the following :

Dragon.hpp Dragon.cpp Mindflayer.hpp Mindflayer.cpp Ghoul.hpp Ghoul.cpp test.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.

Due date:

This project is due on 2/19.
No late submissions will be accepted.

Important

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

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