• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design a system to manage a sporting league

 
sharath reddy vellanki
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The running program will allow the user to initially set up a league and subsequently record results and produce reports.
Brief Description of Classes in Figure 1
The first class to consider is Team. This will hold the data on a single team. The data held will be the name of the team, the number of wins, the number of draws and the number of losses for that team. It should have a single constructor that will set the team name and initialise the numeric values. It will provide getter methods for the attributes. It should also be possible to update the numeric attributes to record the results of a game. Note that the only way to set the team name must be via the constructor � once set it cannot be changed. Our next class is League. This maintains a list of teams in the league. Its attributes will be the name of the league and a list of team objects. You may decide how you store the list of teams. You should provide a constructor which takes the name of the league as a parameter. The constructor should be kept simple. There will be a method to add teams to the league. Another will search for a given team and return the team if it is found otherwise it should return null. There will also be a method to record the result of a match between two teams. This method should take three parameters: the home team name, the away team name and the result for the home team. The result should be a string: �win�, �draw� or �pass�. (Note : if you feel confident you may investigate Java enum). You should also provide a toString method that returns the name of the league and the team details in the form of a league table. (NOTE: you do not need to have sorted the league. This point will be looked at later) NOTE: neither Team nor League have any methods that deal with input or output. It is good object oriented programming practice to separate the I/O from the business classes This brings us to the class LeagueFactory. It has one task: to create a League object. It will do this by means of a method public League createLeague(). This method will collect the necessary data from the user, create and return a new league object. The name of the league should be entered followed by the name of each tea, one name per line. The main I/O for the program is to be contained in the class Controller. This class is expected to have the following attributes: a Scanner and a League. The Controller object will need to know about the league. There will be a menu method to permit the user to interact with the program. The menu will provide four options: Quit exit the program Team get the results for a single team All output the league Result record the result of a match
You will need to write some simple code along the following lines:
CM0718 Program Design and Implementation
Assignment 1
get command while ( command is not quit) { if command first command process first command else if command second command process second command �. get command } The final class is LeagueDriver. This class contains the main method which should merely be used to fire off the program.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50175
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, what is the problem?


Apart from your having been told off for the same question earlier, that is? Don't ask for homework (even less assessments) to be done for you, and don't ask the same question twice.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34965
378
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sharath,
In the event that you and Charan are classmates, this exact same question was asked yesterday.

Nobody here is going to do your assignment for you. If you have a specific question, post it here.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50175
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, they're different people. Sorry, I thought it was the same chap asking twice.

Why don't we give them answers; when they both hand in identical solutions they can both get 0 for it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic