Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

n this java project you will create 4 classes. class SuperHero class Marvel clas

ID: 3531170 • Letter: N

Question

n this java project you will create 4 classes. class SuperHero class Marvel class DC Driver Class called MyAmazingSpringBreak 1. class SuperHero a. Variables String name String superpower static int numberofsuperheroes b. Methods Setters and Getters for both the variables equals method toString method that returns the string "Code Name: " + name + " Super Power: " + superpower c. Constructors Default constructor (no parameters) that simply sets name = "empty" and superpower = "empty" and numberofsuperheroes ++ Constructor with two String parameters (n and s). Sets name = n and superpower = s and numberofsuperheroes ++ 2. class Marvel a. Variables int currentcount An array of SuperHero objects with length 10 :- SuperHero[] team = new SuperHero[10] b. Methods Setters and Getters for both the variables equals method toString method that returns the string "Marvel Team" addSuperHero(String name, String superpower) that takes in two strings (name and superpower). It creates a SuperHero Object with name and superpower and stores it in team[currentcount]. It then does currentcount ++ printTeam() method that goes through the array team[] and prints the toString() method of each object in the array. (Remember the total number of objects in team[] is given by currentcount - 1 c. Constructors Default constructor (no parameters) that simply sets currentcount to 0 3. class DC This class is the same as class Marvel except the toString() method which returns the string "DC Team" 4. class MyAmazingSpringBreak This class obviously has the public static void main(String[] args) method. Here you will first create one object of class Marvel and one object of class DC. Then run a loop for 10 iterations. Inside the loop: Take user input for Superhero Name, Super Power and Team (DC or Marvel). Then add this superhero to Marvel or DC (based on which team the user specified) using the addSuperHero() method. Print each team using their printTeam() methods.

Explanation / Answer

please rate

import java.util.Scanner;

class SuperHero

{

String name;

String superPower;

static int noOfSuperHeroes;

SuperHero()

{

name="";

superPower="";

noOfSuperHeroes++;

}

SuperHero(String n, String s)

{

name=n;

superPower=s;

noOfSuperHeroes++;

}

public void setName(String name)

{

this.name=name;

}

public void setSuperPower(String superPower)

{

this.superPower=superPower;


}

public String getName()

{

return name;

}

public String getSuperPower()

{

return superPower;

}

public String toString()

{

return "Code Name: " + name + " Super Power: " + superPower;

}


}



class Marvel

{

int currentCount;

SuperHero[] team = new SuperHero[10];

Marvel()

{

currentCount=0;


}

public void setCurrentCount(int currentCount )

{

this.currentCount=currentCount;


}

public int getCurrentCount()

{

return currentCount;

}


public String toString()

{

return "Marvel Team";

}


public void addSuperHero(String name, String superPower)

{


team[currentCount]=new SuperHero(name,superPower);

currentCount++;

}

public void printTeam()

{

for(int i=0;i<currentCount;i++)

System.out.println(team[i]);

}

}


class DC

{

int currentCount;

SuperHero[] team = new SuperHero[10];

DC()

{

currentCount=0;


}

public void setCurrentCount(int currentCount )

{

this.currentCount=currentCount;


}

public int getCurrentCount()

{

return currentCount;

}

public String toString()

{

return "DC Team";

}

public void addSuperHero(String name, String superPower)

{


team[currentCount]=new SuperHero(name,superPower);

currentCount++;

}

public void printTeam()

{

for(int i=0;i<currentCount;i++)

System.out.println(team[i]);

}

}



public class MyAmazingSpringBreak {








public static void main(String[] args) {

Marvel objMarvel=new Marvel();

DC objDC=new DC();

String superHeroName;

String superPower;

String team;

Scanner input=new Scanner(System.in);


for(int i=0;i<10;i++)

{

System.out.println("enter super hero name");

superHeroName=input.nextLine();

System.out.println("enter super power");

superPower=input.nextLine();

System.out.println("enter team");

team=input.nextLine();

if(team.equalsIgnoreCase("DC"))

objDC.addSuperHero(superHeroName, superPower);

else

objMarvel.addSuperHero(superHeroName, superPower);


}


System.out.println(objDC);

objDC.printTeam();

System.out.println(" ");

System.out.println(objMarvel);

objMarvel.printTeam();


}

}