top of page

Develop a set of java classes (Team, Game, Driver) where Driver creates lists of teams and games:
ArrayList<Team> teams = new ArrayList<>();
ArrayList<Game> games = new ArrayList<>();
The data for teams and games is in A3.txt. Store this data in Readme .txt.
Teams
The Team class has 2 private fields: city, name.
and begins:
public class Team
{
private String name;
private String city;
Team must have a constructor, getters and setters for all fields, and a toString() method.
There are exactly 7 teams. The first part of Readme.txt can be read and stored using
for (int i=0;i<7;i++){
teams.add(new Team(kb.next(), kb.next()));
}
{NOTE that creating teams is part of Lab 7}
Games
The Game class has private fields for the game date, the home team name, the home team’s
score, the away team, the away team’s score, the game ending.
The Game class begins:
public class Game
{
private String date;
private Team home;
private Team away;
private int homeScore;
private int awayScore;
private String gameEnding;
Game must have a constructor, getters and setters for all fields, and a toString() method.
The game data makes up the rest of the Readme.txt file. Each line has:
a date, the home team name, the home team’s score, the away team, the
away team’s score, the game ending
Driver
Note that the fields home and away in Game are of type Team. To have a proper instance
of Game your Driver class needs a lookup method that returns an instance of Team. For example
it could begin:
/**
* Given a string that is the name of a team and a list of teams,
* this method returns the team in the list that has that name
*/
public static Team lookUpTeam( ArrayList<Team> teams, String teamName)
Your Driver class must display all data that was read in:
 all teams; just use System.out.println(teams);
 all games; just use System.out.println(games);
and then finally your Driver class must print the date of each game, the winning team, the losing
team. The first few lines are:
Date Winner Loser
1/13/2021 MapleLeafs Canadiens
1/13/2021 Canucks Oilers
1/14/2021 Jets Flames

ASC Java Solution

SKU: AMX011
$20.00Price
  • PDF Solution has three Java solution code of Team.java, Game.java and Driver.java with README.txt also. 

bottom of page