Question
In this question, we will simulate set of Football teams playing games in a league. In this question, you will develop the following classes: -
In this question, we will simulate set of Football teams playing games in a league. In this question, you will develop the following classes: - Team in (a) - Score in (b) - Game in (c) - League in (d) - Some extensions to Team are made in a more advanced question (e) Add appropriate validation testing in appropriate places to all classes.
(a) Create the class Team such that: - Constructor takes as input the name of the team and their location (as Strings) - Mutator methods to add points for a win (3) and for a draw (1), named addWin and addDraw respectively. - Accessor methods for the three variables: team name, location and current points - A toString method that returns a String representation of a team in the form:
(b) Create the class Score such that: - The constructor takes as input two int variables: the number of goals for the home Team and away Team respectively. - Score is immutable, and cannot take negative input - Has accessor methods the home and away Team score (number of goals scored): getHomeScore and getAwayScore. The test case for this question is called: testScore
(c) Create the class Game such that: - The constructor takes as input two Team objects and a Score object - A toString method that returns a String in the form for a win:
(d) Create the class League such that: - It has a default constructor - Uses an ArrayList of Teams (to represent the League) - Has a method addGame, which based on the result calls the appropriate addWin or addDraw methods in the corresponding Team object (Hint: you will need to find it in the ArrayList) - A method addTeam, which adds a Team to the League (and prevents duplicate Teams) - A toString method that outputs the contents of the ArrayList (one Team per line displayed in the order they were added to the League; no ordering by points is necessary) The test cases for this question is called: testLeagueOne and testLeagueTwo
(e) Add a method orderedToString to League that reproduces the toString output but orders it by points, and tie breaks by goals scored. Hint: extensions will be needed to Team for this. The test cases for this question is called: testLeagueOrdered and testLeagueOrderedWithTie
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started