• 0

Java League Table


Question

Hey,

I'm looking for some advice on the best method of dealing with the last part of my assignment.

Basically I'm making a Football Score Reader, and the last thing I need to incorporate is a league table.

Basically the results come from results.txt in the following format: <home_team_name> [<home_team_score>] | <away_team_name> [<away_team_score>]

An example of results.txt:

  Quote
Leeds United : Liverpool : 1 : 2

Chelsea : Manchester City : 1 : 1

Aston Villa : Middlesbrough : 3 : 1

Tottenham Hotspur : Stoke City : 0 : 0

Each run through the while loop the variables homeTeam, intHomeScore, awayTeam and intAwayScore are set as you'd presume.

Basically what I need to happen is for a league table to be created in the following format:

-----------------------------------------------------------------------------------------------------------------------

Team | Played| Goal Difference | GamesWon | GamesDrawn | GamesLost | Points

-----------------------------------------------------------------------------------------------------------------------

Liverpool| 15 | +24 | 10 | 2 | 3 | 32

Chelsea | 14 | +20 | 9 | 2 | 3 | 29

Newcastle| 15 | +15 | 8 | 3 | 4 | 27

..

..

Hull | 14 | -20 | 1 | 4 | 9 | 7

  Quote
The Generator program should be extended so that it has the ability to generate a full league table based on the contents match results file. Each time a team has a win it is awarded three points, each time it has a draw it is awarded one point and each time is loses it is awarded zero points. The generated table should have the column headings shown in the example below.

Thanks in advance,

Tom

Link to comment
https://www.neowin.net/forum/topic/957808-java-league-table/
Share on other sites

3 answers to this question

Recommended Posts

  • 0
  On 03/12/2010 at 12:27, El Marto said:

i would just make a Team class with all the attributes needed for the final table. then as your reading in the scores add the points on to Point and goal difference etc. then its just a simple sort to produce the ordered table.

Had a feeling this was the best way, going to redo my project to work in this behaviour, thanks for the advice.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.