File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Design a system to manage a sporting league Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Design a system to manage a sporting league" Watch "Design a system to manage a sporting league" New topic

Design a system to manage a sporting league

sharath reddy vellanki

Joined: Mar 16, 2008
Posts: 1
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

Joined: Oct 13, 2005
Posts: 46375
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

Joined: May 26, 2003
Posts: 33124

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46375
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.
I agree. Here's the link:
subject: Design a system to manage a sporting league
It's not a secret anymore!