## CS 1401 Assignment #12

**Date Assigned:** Tuesday, November 22, 2005 or
Wednesday, November 23, 2005.
**Due Date:** before the end of your last lab session, on Wednesday November 30 or on Thursday December 1, 2005.

**Goals:** to learn how to use arrays of objects.

**Points:**
This assignment is worth a total of 20 points. No late assignments
will be accepted, but credit will be given for partially completed
assignments turned in on time.

**Assignment:**
This assignment is a continuation of Assignment 11 about the UTEP soccer team.
As in that assignment,
the results of all the games are stored in a file in which each line represents a score. For example, 5:3 means
that the UTEP team scored 5 goals, while the opposite team scored only 3 goals.

In soccer, a win (like 5:3) brings 2 points, a tie (like 3:3)
brings 1 point, and a loss (like 3:5) brings 0 points. The team with the largest number of points wins.
If two or more
teams get the same number of points, then the referees decide which of these teams is the champion by
looking at the overall numbers of goals scored and goals missed by each of these teams.

The difference with the previous assignment is that instead of two arrays of numbers, we will now have arrays of objects.

Define a class *GameScore*; each object of this class must have a field *gained* and a field *missed*. For example, if the score of a game is 5:3, then the field *gained* should contain 5 and the field *missed* should contain 3. Use encapsulation; in other words, make sure that these fields are private and are only accessible via methods.

Write an application that:

- asks the user for a name of the file where the scores are stored;
you can assume that no more than 100 games were played;
- reads the scores from this file, line by line,
into an array
*score* of objects of type *GameScore*;
at the same time, the program should compute the overall
number of games played;
- computes and displays:
- the overall number of points gained by the UTEP team,
- the
overall number of goals scored by UTEP team, and
- the overall number of goals lost by UTEP team.

**Example** (same as in Assignment 11)

If UTEP played 3 games, with scores 5:3, 1:2, and 7:0, then:

- in the first game, we gained 2 points;
- in the second game, we gained 0 points; and
- in the third game, we gained 2 points again.

The overall number of points gained is thus 2 + 0 + 2 = 4. Also:
- the overall number of goals scored is 5 + 1 + 7 = 13, and
- the overall number of goals missed is 3 + 2 + 0 = 5.

**Deliverables:** as announced in the labs.