I'm given 2 classes. It's basically a game scoreboard and it runs through all the values to determine who the winner is. No user input is needed.
Sample output at the end looks like this:
Vancouver - 3 wins, 2 losses, 0 ties = 6 total points Calgary - 2 wins, 3 losses, 2 ties = 6 total points Edmonton - 1 wins, 3 losses, 2 ties = 4 total points Toronto - 2 wins, 3 losses, 2 ties = 6 total points Ottawa - 4 wins, 3 losses, 1 ties = 9 total points Montreal - 4 wins, 2 losses, 1 ties = 9 total points The season winner(s) with 9 points Ottawa Montreal
The two classes are Game.class and Schedule.class
Game.class
public class Game { public Game(String s, String s1, int i, int j) { homeTeam = s; awayTeam = s1; homeScore = i; awayScore = j; } public String getHomeTeam() { return homeTeam; } public String getAwayTeam() { return awayTeam; } public int getHomeScore() { return homeScore; } public int getAwayScore() { return awayScore; } private String homeTeam; private String awayTeam; private int homeScore; private int awayScore; }
Schedule.class
public class Schedule { public Schedule() { games = new Game[20]; games[0] = new Game(teams[0], teams[1], 5, 3); games[1] = new Game(teams[1], teams[2], 4, 4); games[2] = new Game(teams[2], teams[3], 3, 3); games[3] = new Game(teams[4], teams[3], 2, 4); games[4] = new Game(teams[4], teams[5], 6, 3); games[5] = new Game(teams[5], teams[1], 5, 4); games[6] = new Game(teams[0], teams[3], 4, 3); games[7] = new Game(teams[1], teams[4], 3, 4); games[8] = new Game(teams[2], teams[0], 2, 3); games[9] = new Game(teams[3], teams[1], 1, 4); games[10] = new Game(teams[4], teams[2], 5, 3); games[11] = new Game(teams[5], teams[3], 4, 4); games[12] = new Game(teams[1], teams[4], 3, 3); games[13] = new Game(teams[2], teams[5], 2, 4); games[14] = new Game(teams[3], teams[5], 1, 3); games[15] = new Game(teams[4], teams[0], 5, 4); games[16] = new Game(teams[5], teams[4], 4, 3); games[17] = new Game(teams[0], teams[3], 3, 4); games[18] = new Game(teams[5], teams[2], 2, 3); games[19] = new Game(teams[4], teams[1], 1, 4); } public String[] getTeams() { String as[] = { "Vancouver", "Calgary", "Edmonton", "Toronto", "Ottawa", "Montreal" }; return as; } public Game getGame(int i) { return games[i]; } public static final int GAMES = 20; private String teams[] = { "Vancouver", "Calgary", "Edmonton", "Toronto", "Ottawa", "Montreal" }; private Game games[]; }
I admit that I really don't know where to start with this. I know I need to make a class that will invoke a main method to integrate the other 2 classes together. So it will output what I showed earlier to determine the winner, based on the score and games.
They provide these classes and I need to work on them. I don't understand how games[] is passed through. Under the schedule.class, is it just a parameter that's done 19 times? Any help is greatly appreciated. I really don't understand how to start with this.