Write a Java class that implements the concept of a sports team (SportsTeam clas
ID: 3697410 • Letter: W
Question
Write a Java class that implements the concept of a sports team (SportsTeam class) that has the following components: Attributes: Mascot, City, Wins, and Losses Constructor that initializes Mascot and City attributes. Getter and Setter methods are required for all four attributes. Inside a test class (TestSportsTeam), do the following: Create an array of 4 sports team objects with the following arrangement of objects: object team I: Mascot = "Falcons", City=" Atlanta" object team2:Mascot ="Bucs", City='Tampa Bay"; Mascot ="Saints", City="New Orleans" Mascot ="Panthers", City="Carolina" For each object, randomly assign a value (no greater than 16) to attribute Wins. Then set the Losses attribute to be equal to 16 - Wins. Next, display a header with the following format (City Mascot Wins Losses WinPct) as shown below. Below the header, display (printout) the team that has the most wins and the fewest wins. Compute the win points as follows: WinPct = Wins/(Wins+Losses). Sample outputExplanation / Answer
public class SportsTeam {
private String mascot;
private String city;
private int wins;
private int losses;
public SportsTeam(String mascot, String city) {
this.mascot = mascot;
this.city = city;
}
public String getMascot() {
return mascot;
}
public void setMascot(String mascot) {
this.mascot = mascot;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public int getWins() {
return wins;
}
public void setWins(int wins) {
this.wins = wins;
}
public int getLosses() {
return losses;
}
public void setLosses(int losses) {
this.losses = losses;
}
}
public class TestSportsTeam {
public static void main(String[] args) {
double winpct;
SportsTeam team1 = new SportsTeam("Falcons", "Atlanta");
SportsTeam team2 = new SportsTeam("Bucs", "Tampa Bay");
SportsTeam team3 = new SportsTeam("Saints", "New Orleans");
SportsTeam team4 = new SportsTeam("Panthers", "Carolina");
team1.setWins(4);
team1.setLosses(12);
team3.setWins(13);
team3.setLosses(3);
System.out.println("City :" + team1.getCity());
System.out.println("Mascot :" + team1.getMascot());
System.out.println("City : " + team3.getCity());
System.out.println("Mascot : " + team3.getMascot());
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.