Department of Computer Science Level 4 Quest: Ship Dodger CPSC 2376 Programming II Ramiro Serrano Vergel Department of Computer Science Level 4 Quest: Ship Dodger CPSC 2376 Programming II Programming...

help with assignment


Department of Computer Science Level 4 Quest: Ship Dodger CPSC 2376 Programming II Ramiro Serrano Vergel Department of Computer Science Level 4 Quest: Ship Dodger CPSC 2376 Programming II Programming Concepts · Inheritance · Polymorphism · Abstract Classes Task Summary: We are going to modify a program by creating an inheritance structure of classes by adding two abstract classes and a third concrete class that will create a circular object that is a power up that will heal the player’s ship. Say that 5 times fast! For this assignment you will learn and demonstrate how to: 1. create an inheritance structure 2. create and overload virtual and purely virtual methods 3. use abstract classes to fill out the hierarchical structure. Base Code Functionality The instructor has provided all the necessary · GUI source code to display the game (GUI.h, GUI.cpp, Timer.h, Timer.cpp), · base main source code (quest.4.cpp), · semi-empty class files (Object.h, Object.cpp, RandomFallingObject.h, RandomFallingObject.cpp, PowerUp.h, PowerUp.cpp, Ship.h, Ship.cpp, Block.h, Block.cpp) · quest constants and structs(constants.h) The class hierarchy looks like the following: Figure 1: Class Hierarchy Structure Not included in Figure 1 are any necessary getters and setters for the classes. A quick overview of UML: For those who are not familiar with UML (Unified Modeling Language), each box represents a class. The class members are listed first and then the class methods. + public - private # protected The identifier is listed next, followed by a colon and the type. For methods, only the type of the parameter is listed. The type of arrows connecting the classes indicate an is-a relationship corresponding to inheritance. Most of this quest is about understanding, rearranging code and setting up the hierarchy properly. The Ship class has a heal method adds the passed in int to the ships health. The code that adjusts the ship’s color based on the ship’s health is the colorize method. The PowerUp class should be essentially the same as the Block class, but also has a radius, which has been added to the Dimension struct, and call’s the ship’s heal method instead of takeDamage. Object Class: This is an abstract class, and as such, does not have much in its .cpp file. There should be a few getters for the components of it’s sprite member, and a default constructor that does nothing other than set the values of it’s sprite member to all 0’s. The Command enum has also been moved to this class. Ship Class: This is the player and this class has colorize and heal methods. It’s sprite member should be part of the inherited Object class, along with all it’s getters. RandomFallingObject Class: Since the children of the class are essentially identical except for their update methods, this class should steal all the members and methods from the Block class. Including the code for the default constructor. The radius of the Dimensions struct is calculated the same as the length/height. The radius is ignored by the Block class. PowerUp and Block Classes: These classes have little for themselves. They each have an update method that is essentially the same as Block’s update. The only difference being that the PowerUp class call’s the Ship’s heal method upon collision. They each have a default constructor which simply calls the RandomFallingObject class’s default constructor. The PowerUp class does have a static const float PI{3.14} member for calculating area. In the constructor of this class, not only do you need to call the RandomFallingObject’s constructor, but also set the height and width of the class to the diameter of the circle (2* it’s radius). This should override the random values set to the length and height by the RandomFalling Object class. The PowerUp constructor also need to update the velocity (which is calculated wrong). Use the formula for the area of the circle, then multiply that value by .03. The velocity of the circles is going to be less than a Block of the same area. The values passed into the heal/takeDamage methods will be changed to the velocity of the object colliding. Required Code Functionality Task 0: Download Base Files (easy) You will download the folder that contain the following files: · quest.1.cpp, · GUI.cpp, · GUI.h, · Timer.h, · Timer.cpp · constants.h · Object.h · Object.cpp · RandomFallingObject.h · RandomFallingObject.cpp · PowerUp.h · PowerUp.cpp · Ship.h · Ship.cpp · Block.h · Block.cpp The quest5.cpp file contains the int main function. The Timer.cpp, Timer.h, GUI.cpp and GUI.h files contain the logic necessary to run the GUI and regulate the framerate of the program. The constants.h file contain the structs and constants you will be using for your program. The class files have partly created classes ready for you to fill out. Task 1: Test that your code runs (easy) After you download the code, it should run without errors. You should see just your player! And control it with the arrow keys. Task 2: Complete files for Object, RandomFallingObject, and PowerUp classes (easy). Complete and uncomment the code for the three classes. Also, get the .h files set up based upon the UML diagram in Figure 1. Task 3: Set up inheritance and move code to parent classes (moderate) Move any code from the Ship and Block classes that need to be in parent classes according the the above instructions. Some code has been commented to help understanding what is the final result. Also, set up the hierarchical structure, in code, according to the UML diagram in Figure 1. Task 4: Write new code (moderate) Complete the Ship class’s heal method and the PowerUp class’s update method to match the above description. Remove code from Ship class and Block that is moved to other classes. Make any modifications mentioned in the above instructions to make the code work. Task 5: Submit Completed Assignment (easy) Create a zip file of your project and load it in BB. Submit a 5 minute video walkthrough of your code in Blackboard! Important How to go about writing this code. 1. Immediately read this quest specification carefully. 2. Download and build the project. 3. Run the base code. 4. Review the code provided. 5. Write in English the steps that each function should perform. 6. Use this plan to write the code. 7. Write the code incrementally, compiling often. Save your work and commit often! 8. Ask questions early and often! Bonus XP: (200XP) A Friend’s a Friend Forever: On a very rare occasion (.001 on Bernoulli distribution), a Ship object should also fall. If it collides with the current Ship(s) it gets added to the side of your current ship (you can pick up two extra ships at a time, making a three wide set of triangles). The game now ends when all your ships are destroyed. If the ship in the middle gets destroyed before the outside two, the outside two should come together, so that there is never a gap between ships. You may consider a vector players, to keep track of these ships. Also, the Ship class’s update method will need to modified extensively. It will, essentially, have two states. One, when it is falling, and being deleted if it reaches the bottom of the screen. The state will be switched to an active state when it is joined with the player ship. A simple boolean member should help ensure the correct code is run. A good programmer will create private methods for the code for each of these states.
Nov 06, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here