Question: You re a programmer at Marvel Studios, and there are way too many superheroes to keep track of. You re tasked with creating a






You re a programmer at Marvel Studios, and there are way too many superheroes to keep track of. You re tasked with creating a superhero database representing the many superheroes in an organized way that utilizes inheritance and hierarchies! Solution Description For this assignment, create files with the following names: Superhero.java ChargedSuperhero.java FlyingSuperhero.java Creating a Superhero 1. Create a class called Superhero that has the following instance data: a. name: All superheroes have a code name! This protected variable should be called name and it should be a String. b. health: superheroes have health so they should have a set amount of health points. Their health can only be represented through whole numbers. This variable should be protected. c. damage: superheroes do a set amount of attack damage in each attack! (More on this later) This attack can only be represented through whole numbers. This variable should be protected. 2. Superhero should have the following constructors: a. Include a no-argument constructor that sets the following values name: Anonymous Superhero health: 100 damage: 8 b. Include a constructor that takes in name, health, and damage values in this order. c. Make sure the constructor parameters have the same type as their corresponding fields. d. NOTE: Constructor chaining MUST be used where possible. 3. Superhero should have the following instance methods: Below you are given the method signatures and specification for the Superhero class. Make sure these are instance methods and the signatures match exactly. a. tostring method Must properly override Object s toString() method. 0 Dashboard PE04.pdf !!! Apps Bookmarks BuzzPort | Georgia... Programming Exercise 4 Type here to search https://gatech.instructure.com/courses/192688/assignments/803048 X Canvas o Mail Outlook O Post Question courseoff Should return: b. equals method. . Learn Java - Free In... + zy zyBooks OOP PRACTICE SUPERHERO Name: {name} Health: (health} Strength: {damage} Hint: Use new line characters and don t include the brackets! Should override Object s equals () method. Two superheroes are equal if they have the same name, health, and damage. c. attack (Superhero other) method: Deals damage to the superhero that is taken in as a parameter. Only deals damage if the attacking superhero has more than 0 health. The amount of damage dealt to the other superhero should be equal to damage. Other s health should go down by the value of damage (this Superhero s damage, not the other Superhero s). CS 2050 TEXTBOOK Page < Creating a ChargedSuperhero This class is a child of Superhero and should inherit from it. An example of this kind of Their health should not go below O because of the damage, if it does, set it to 0. This method should return nothing. 2 (?) of 6 Download 92F Sunny Other bookmarks i Info ZOOM + J Reading list X Close X 4:24 PM 6/15/2021 0 Dashboard PE04.pdf !!! Apps Bookmarks BuzzPort | Georgia... Programming Exercise 4 Type here to search https://gatech.instructure.com/courses/192688/assignments/803048 X Canvas o Mail Outlook O II Post Question courseoff Creating a ChargedSuperhero This class is a child of Superhero and should inherit from it. An example of this kind of superhero is Black Panther. H Learn Java - Free In... zy zyBooks 1. Create a class called ChargedSuperhero that has the following instance data: a. charged: ChargedSuperheroes have a unique suit that allows them to charge energy and unleash a burst of energy. Create a private variable that represents whether their suit is charged up or not named charged. 2. ChargedSuperhero should have the following constructors: a. Include a constructor that takes in name, health, damage, and charged in this order. . + b. Include a default no-arguments constructor that creates a ChargedSuperhero with the following default values: name is Anonymous ChargedSuperhero , a. tostring method c. Ensure that you are calling the parent constructor appropriately. 3. ChargedSuperhero should have the following instance methods: OOP PRACTICE health is 30, damage is 10, charged is false. Use constructor chaining to call the other constructor in this class with default values. Must properly override Object s toString() method. Should return: SUPERHERO Name: {name} O CS 2050 TEXTBOOK Page < 2 ??? of 6 Download 92F Sunny Other bookmarks i Info ZOOM + B Reading list X Close X 4:25 PM 6/15/2021 0 Dashboard PE04.pdf !!! Apps Bookmarks BuzzPort | Georgia... Programming Exercise 4 Type here to search https://gatech.instructure.com/courses/192688/assignments/803048 X Canvas o Mail Outlook O Post Question . H b. equals () method courseoff Learn Java - Free In... zy zyBooks Health: {health} Strength: {damage} + Suit Charged: (charged) Must utilize Superhero s toString() method to optimize code. c. attack (Superhero other) method: Overrides the Superhero attack method. OOP PRACTICE Should override Object s equals () method. Two ChargedSuperhero are equal if they have the same name, health, damage, and charged values. Must reuse code using Superhero s equals () method. Deals damage to the superhero that is taken in as a parameter. Only deals damage if the attacking superhero has more than 0 health. Creating a Flying Superhero This class is a child of Superhero and should inherit from it. An example of this kind of superhero is Captain Marvel. CS 2050 TEXTBOOK Page If the suit of the ChargedSuperhero that called this method is charged, the ChargedSuperhero will deal damage equal to twice the amount of the value of damage (this ChargedSuperhero s damage, not the other Superhero s). If the suit of the ChargedSuperhero is NOT charged (charged equals false), deal damage equal to the value of damage (this ChargedSuperhero s damage, not the other Superhero s). The defending superhero s health should not go below 0. If it does, set it back to 0. 4. Create a class called FlyingSuperhero that has the following instance data: a. flying: a FlyingSuperhero has a unique suit that allows them to fly. Create a private variable that represents whether they are in flight or not called flying 5. Flying Superhero should have the following constructors: a. Include a constructor that takes in name, health, damage, and flying in this order. b. Include a default no-arguments constructor that creates a FlyingSuperhero with the following default values: name is Anonymous FlyingSuperhero , health is 40, 3 (?) of 6 Download 92F Sunny Other bookmarks i Info ZOOM + B Reading list X Close X 4:25 PM 6/15/2021 0 Dashboard PE04.pdf !!! Apps Bookmarks BuzzPort | Georgia... Programming Exercise 4 Type here to search https://gatech.instructure.com/courses/192688/assignments/803048 X Canvas o Mail Outlook O Post Question H courseoff Learn Java - Free In... zy zyBooks + damage is 7, flying is false. Use constructor chaining to call the other constructor in this class with default values. c. Ensure that you are calling the parent constructor appropriately. 6. Flying Superhero should have the following instance methods: a. tostring method Must properly override Object s toString() method. . Should return: SUPERHERO Name: {name} Health: {health} Strength: {damage} Flying: (flying} OOP PRACTICE b. equals() method Must utilize Superhero s toString() method to optimize code. Should override Object s equals () method. Two FlyingSuperhero are equal if they have the same name, health, damage, and flying values. Must reuse code using Superhero s equals() method. CS 2050 TEXTBOOK Page (?) of 6 Download 92F Sunny Other bookmarks i Info ZOOM + B Reading list X Close X 4:25 PM 6/15/2021 0 Dashboard PE04.pdf !!! Apps Bookmarks BuzzPort | Georgia... Programming Exercise 4 Type here to search https://gatech.instructure.com/courses/192688/assignments/803048 X Canvas o Mail Outlook O II Post Question b. equals () method courseoff H + Learn Java - Free In... zy zyBooks c. attack (Superhero other) method: Overrides the Superhero s attack method. Deals damage to the superhero that is taken in as a parameter. Only deals damage if the attacking superhero has more than 0 health. NOTES & HINTS: Should override Object s equals () method. Two FlyingSuperhero are equal if they have the same name, health, damage, and flying values. Must reuse code using Superhero s equals () method. OOP PRACTICE CS 2050 TEXTBOOK Page If FlyingSuperhero is flying, there is a 50% chance that FlyingSuperhero will deal damage equal to 3x the amount of the value of damage. If chance fails, deal damage equal to the value of damage (in both cases, use this Flying Superhero s damage, not the other Superhero s). o HINT: Use Random or Math methods to calculate this chance. (HINT: there is a nextBoolean method in the Random class but you can also use numbers) If FlyingSuperhero is not flying, deal damage equal to the value of damage. The defending superhero s health should not go below 0. If it does, set it back to 0. You must use the exact method signatures provided. If we did not explicitly specify what a method should return you can assume it returns nothing Make sure that you call any parent constructors appropriately using super. Make sure that you are overriding methods correctly and reusing code when possible. When overriding a method, if you use the @Override tag, you do NOT need to javadoc that method (javadocs NOT required for this assignment, but feel free to practice using them)! Unless specified, you are free to choose access modifiers for your variables. Just ensure they follow the rules of encapsulation! And, add any necessary getters and setters. Test your code often! Write you own driver class with a main method that creates objects with different constructors and calls methods on them. (?) of 6 Download 92F Sunny Other bookmarks i Info ZOOM + J Reading list X Close X 4:26 PM 6/15/2021 0 Dashboard PE04.pdf !!! Apps Bookmarks BuzzPort | Georgia... Programming Exercise 4 Type here to search https://gatech.instructure.com/courses/192688/assignments/803048 X Canvas o Mail Outlook O Post Question courseoff Learn Java - Free In... + zy zyBooks OOP PRACTICE Checkstyle You must run checkstyle on your submission. If you don t have checkstyle yet, download it from Canvas - > Files -> Resources in the A/B/GR section and in Modules > General Information in the D section. Place var (the reserved keyword) System.exit Collaboration CS 2050 TEXTBOOK it in the same folder as the files you want checkstyled. Run checkstyle on your code like so: $ java -jar checkstyle-8.28.jar yourFileName.java Starting audit... Audit done. The message above means there were no Checkstyle errors. If you had any errors, they would show up above this message, and the number at the end would be the points we would take off (limited by Allowed Imports To prevent trivialization of the assignment, you are only allowed to import the following classes: . java.util.Random Page the checkstyle cap mentioned in the Rubric section). In future homeworks we will be increasing this cap, so get into the habit of fixing these style errors early! Checkstyle will be required on this homework, with a MAXIMUM point deduction of 10. Feature Restrictions There are a few features and methods in Java that overly simplify the concepts we are trying to teach or break our auto grader. For that reason, do not use any of the following in your final submission: 5 (?) of 6 Download 92F Sunny Other bookmarks i Info ZOOM + J Reading list X Close X 4:26 PM 6/15/2021
Step by Step Solution
3.38 Rating (148 Votes )
There are 3 Steps involved in it
SolutionsJava script Three files are given as below as per your requirement 1Superherojava EXPLANATION Creating classes to learn a bit about java Super hero classes class Hero private Costume herocs p... View full answer
Get step-by-step solutions from verified subject matter experts
Document Format (2 attachments)
60d5e1d2253b0_225437.pdf
180 KBs PDF File
60d5e1d2253b0_225437.docx
120 KBs Word File
