You re a programmer at Marvel Studios, and there are way too many superheroes to keep...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 92°F 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 92°F 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 92°F 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 92°F 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 92°F 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 92°F Sunny Other bookmarks i Info ZOOM + J Reading list X Close X 4:26 PM 6/15/2021 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 92°F 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 92°F 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 92°F 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 92°F 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 92°F 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 92°F Sunny Other bookmarks i Info ZOOM + J Reading list X Close X 4:26 PM 6/15/2021
Expert Answer:
Answer rating: 100% (QA)
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 the full answer
Related Book For
Vector Mechanics for Engineers Statics and Dynamics
ISBN: 978-0073212227
8th Edition
Authors: Ferdinand Beer, E. Russell Johnston, Jr., Elliot Eisenberg, William Clausen, David Mazurek, Phillip Cornwell
Posted Date:
Students also viewed these programming questions
-
I can get Mickey to download any data I need from the Web or our server to my PC, DeWitt Miwaye, an upper-level manager for Yumtime Foods (a Midwest food wholesaler), tells you. Getting data is no...
-
This problem should be completed with database software, such as Microsoft Access. As directed by your instructor, submit the completed database file and the printouts noted below. 1. Using the E-R...
-
This problem should be completed with database software, such as Micro soft Access. As directed by your instructor, submit the completed data-base file and the printouts noted below. 1. Using the E-R...
-
Look again at the financial forecasts for Growth-Tech given in Table 4.3. This time assume you know that the opportunity cost of capital is r = .12 (discard the .099 figure calculated in the text)....
-
Using the data for Adobe Systems Inc. (Nasdaq: ADBE), presented below: a. Calculate the ratio of each years' data to the previous year for each of the above items for Adobe. For example, for the year...
-
A common characterization of obese individuals is that their body mass index is at least 30 [BMI = weight/(height)2, where height is in meters and weight is in kilograms]. The article "The Impact of...
-
Prove that the predictable It's formula is \[\begin{aligned}F\left(t, X_{t} ight)= & F\left(0, X_{0} ight)+\int_{0}^{t} \partial_{s} F\left(s, X_{s} ight) d s \\& +\sum_{i=1}^{d} \int_{0}^{t}...
-
Valport Valve Company manufactured 15,600 units during March of a control valve used by milk processors in its Shreveport plant. Records indicated the following: Direct...
-
Calculating velocity pressure is tedious and one has to remember to convert lbm to lbf because pressure is force per area. For air duct calculations there is a convenient equation, which is as...
-
A company's debt is given by a bond that will mature in two years. After two years the company will terminate all activity. The company unlevered equity value in two years can be $17 millions with a...
-
The statement of financial position of Kingbird Limited follows for the current year, 2020: KINGBIRD LIMITED Statement of Financial Position December 31, 2020 Current assets $135,660 Current...
-
how to solve that a static method hasOnePeak that returns true if its LinkedList argument has a single peak, and false otherwise. This means that the sequence of values consists wholly of an...
-
Interview a leader or negotiator from a different gender and/or race, ethnicity, culture, religion, socio-economic level, or generation than you about how they handled leadership and negotiation...
-
Healthcare project management is vital in ensuring that healthcare organizations can improve their operations and deliver high-quality care to patients safely and efficiently. Project managers in the...
-
The owners of Records Unlimited are eligible for trade discounts of 21%, 15% and 9% off of the merchandise that they want to buy for their stores. If the list price of the items is $102, what is the...
-
A company employs a single machine mechanic to maintain all the equipment. It is estimated that, on average, 4 machines break down in an hour. The average time taken to repair a machine is estimated...
-
Part 3 Happy Banking Company has ten automatic teller machines (ATM) spread throughout the city maintained by the ATM Department. You have been assigned the task of determining the cost of operating...
-
Q:1 Take any product or service offered in Pakistan and apply all determinents of customer Perceived value ?
-
The L-shaped member ACB is supported by a pin and brackets at C and by an inextensible cord attached at A and B and passing over a frictionless pulley at D. Determine (a) The tension in the cord, (b)...
-
Bars AB and BE, each of weight 8 lb, are welded together and are pin-connected to two links AC and BD. Knowing that the assembly is released from rest in the position shown and neglecting the masses...
-
Two bars are attached to a single spring of constant k that is unstretched when the bars are vertical. Determine the range of values of P for which the equilibrium of the system is stable in the...
-
Summer and winter constellations are different because (a) of the spin of Earth about its polar axis. (b) the night sky faces in opposite directions in summer and winter. (c) of the tilt of Earths...
-
The longest-lived stars are those of (a) low mass. (b) high mass. (c) intermediate mass. (d) infinite mass.
-
What is the star nearest Earth? (a) Proxima Centauri (b) Polaris (c) Mercury (d) the Sun
Study smarter with the SolutionInn App