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

Write a Java class that implements the concept of a sports team (SportsTeam clas

ID: 3770566 • Letter: W

Question

Write a Java class that implements the concept of a sports team (SportsTeam class) that has the following attributes: Mascot, City, Wins, and Losses. The constructor must initialize Mascot and City attributes. Getter and Setter methods are required for all four attributes.

Inside a test class (TestSportsTeam), create an array of 4 sports team objects with the following arrangement of objects:

1) object team1: Mascot = “Falcons”, City=”Atlanta”

2) object team2: Mascot =”Bucs”, City=”Tampa Bay”;

3) object team3: Mascot =”Saints”, City=”New Orleans”

4) object team4: 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 output is:

City Mascot Wins Losses WinPct

Atlanta Falcons 4 12 0.25

New Orleans Saints 13 3 0.82

Explanation / Answer

SportsTeam.java ---------------------------------------------------------------------- import java.util.Random; /** * Created by GOD on 10-12-2015. */ public class SportsTeam { private String Mascot,City; private int Wins,Losses; /*Default Constructor*/ public SportsTeam(){ } /*Constructor to initialize*/ public SportsTeam(String Mascot, String City){ this.Mascot = Mascot; this.City = City; } /*Setter Methods*/ public void setMascot(String Mascot){ this.Mascot = Mascot; } public void setCity(String City){ this.City = City; } public void setWins(int Wins){ this.Wins = Wins; } public void setLosses(int Losses){ this.Losses = Losses; } /*Getter Methods*/ public String getMascot(){ return Mascot; } public String getCity(){ return City; } public int getWins(){ return Wins; } public int getLosses(){ return Losses; } } class TestSportsTeam { public static void main(String args[]){ SportsTeam[] m_Team = new SportsTeam[4]; m_Team[0] = new SportsTeam("Falcons","Atlanta"); m_Team[1] = new SportsTeam("Bucs","Tampa Bay"); m_Team[2] = new SportsTeam("Saints","New Orleans"); m_Team[3] = new SportsTeam("Panthers","Carolina"); Random number = new Random(); for(SportsTeam tmp : m_Team){ tmp.setWins(number.nextInt(17)); tmp.setLosses(16-tmp.getWins()); } /*for(SportsTeam tmp : m_Team){ System.out.println(tmp.getMascot() + " : " + tmp.getWins() + " , " + tmp.getLosses()); }*/ int max=-1,min=17; SportsTeam maxTeam = null; SportsTeam minTeam = null; for(SportsTeam tmp : m_Team){ if(tmp.getWins() > max){ max = tmp.getWins(); maxTeam = tmp; } if(tmp.getWins()
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote