3 Below is a class definition for the abstract class "SuperHero" public abstract class Super Hero 2 { private String sui

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

3 Below is a class definition for the abstract class "SuperHero" public abstract class Super Hero 2 { private String sui

Post by answerhappygod »

3 Below Is A Class Definition For The Abstract Class Superhero Public Abstract Class Super Hero 2 Private String Sui 1
3 Below Is A Class Definition For The Abstract Class Superhero Public Abstract Class Super Hero 2 Private String Sui 1 (136.2 KiB) Viewed 48 times
Part 2: Write a “SuperHeroDriver” class
that creates instances of an AsteroidMan, FriedEggMan, and YourHero
and initializes each of them with an arbitrary suitColor and
hasCape instance variable. Add each of these Superheroes to an
ArrayList of type SuperHero called “heroes” and print each
superhero’s suitColor, hasCape instance variable, and motto using a
for loop or a for-each loop.
Part 3: Create 3x3 2D array called
“capedHeroes” that can hold objects of type SuperHero. For every
superhero in the “heroes” ArrayList that has a cape, add that
SuperHero to the “capedHeroes” 2D array starting at (0,0) AND
remove that SuperHero from the “Superheroes” ArrayList. Empty
“spaces” in the 2D array should be filled with the value of “null.”
Use a separate nested for loop to perform this operation. Your
algorithm should work for any number of heroes in the original
ArrayList of “SuperHero”.
Part 4: Print the suitColor, hasCape, and
motto for each hero in the “hero” ArrayList and “capedHeroes” 2D
array to verify their contents after completing Part 3 above.
Thank you! Java
3 Below is a class definition for the abstract class "SuperHero" public abstract class Super Hero 2 { private String suitColor; private boolean hasCape; public SuperHero) { this.suitColor = new String(); this.hasCape = false; } // end zero-arg constructor Super Hero 8 9 1e 11 12 13 14 15 16 public SuperHero(String suitColor, boolean hasCape) { this.suitColor - suitColor; this.hasCape - hasCape; } // end two-argument constructor Super Hero public void setSuitColor (String suitColor) { this.suitColor = new String( suitColor ); } // end method setSuitColor 17 18 19 20 21 22 23 24 26 26 27 20 23 3 public String getsuitColor() { return suitColor: } // end method getsuitColor public void setCape(boolean cape) { this.hasCape - cape: } // end method setCape public boolean 1sCaped() { return hasCape : } // end method isCaped public abstract String getName(); 31 33 34 35 36 37 30 41 public abstract String motto(): public String toString() 45 return getName() + "it" + 1sCaped() + "it" + getSuitColor() + "It + motto): 47 end abstract class Superhero
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply