SWEN131 Group Project 2

This project is about designing classes, objects, and/or interfaces, and using fields, ArrayLists, and/or arrays to represent and model data. You will read data from a file, and load it into your system for the user to work with.

First, you should read the problem description below and the description of the data format. In your groups, discuss how you would structure your program to deal with the data and tasks required. You may find it useful to use diagrams on paper, the computer, or on the whiteboard to think about what you're planning.

Write down your design at a high level. If you're considering or considered alternative approaches, note them as well.

You can spend as long as you like on the design stage, but make sure you do move on. If you want, you can do it in stages. You each need to submit a plain text file design.txt describing your design. You may share this file between you. List the people in your group in the file.

Then, implement the system. If you wish, you may extend it further, but begin by making the tasks below work.

A base project is available to start you off.

You will write your code together this time, using "pair programming". In pair programming you share a computer, with one person typing at any one time, and swap places every so often. For this project, we suggest swapping places every half hour or so.

Finally, write a brief report about your project, the design, and the development process. Write this report individually. The report need only be as long as necessary, but make sure you mention anything you want known or that might be useful in marking your project.

This project is due at 4p.m. in the submission system. This is a hard deadline. You should submit all of your code, your design in design.txt, and your individual report in report.txt. You may find Eclipse useful for writing up your report and design: you can make new text files by right-clicking and choosing "New → Untitled Text File".

Submission

Submit your project by 4p.m. in the SWEN131 assignment submission system .

If you finish early, make sure you have submitted your files, and you can leave.

Problem

You are building a tool to help a sport league handle their records. You are working with a data file listing all the teams in the league, their respective coaches, and their players.

You need to load the team data from the file and represent it as objects in your program. Decide which classes, interfaces, objects, and other structures you will use.

A simple user interface is provided in the base project. You can change this interface if you wish, or use it as is. You can use the graphical output, text interaction, or any comnbination of the two.

There are several users of your system with different goals and tasks to accomplish. These are listed below.

Data format

The data file is plain text.

Each team's name is listed on one line, followed by the name of the coach.

The next line is the number of players in the team. Following that, the players are listed one by one.

For each player, the first line lists the positions they play, followed by their name on the same line.

The next two lines give the player's height (in centimetres) and place of birth.

An example trivial file might be:

Giants
Lemuel
1
AB,CD Glumdalclitch
1560
Brobdingnag
        

In this file, the team "Giants" is coached by Lemuel, has one player, Glumdalclitch, who plays two positions, AB and CD, with a height of 1560 and a birthplace of Brobdingnag.

The data file is included in the base project, or is available online. There is also a simplified version of the data, which includes zero players in each team.

Tasks

The clients of your system have several requirements and tasks they want to perform using it. Try to design and build your system to allow them.

You may want to start at the top and work downwards. If you are looking for extensions to do, consider:

Hints

Opening a file to read
try {
    Scanner scanner = new Scanner(new File(filename));
    ...
    scanner.close();
} catch (IOException e) {
    UI.println("A file-reading error: " + e);
}
Useful methods on Scanners
A common pattern with Scanners
Many file formats include a number saying how many times a part of the data will be repeated afterwards. In these cases, it's common to read the number, and then loop that many times over the code loading the repeated data.
Splitting a string apart
You can split a string apart using the String[] split(String delimiter) method:
String s = "123xyz456xyz789";
String[] parts = s.split("xyz");
                
This method returns an array of Strings, with one item for each substring starting and/or ending with the delimiter. In the example above, parts has length 3, and contains "123", "456", and "789".
Creating an object
If you have a class:
class Example {
    public Example(String s) {
        ...
    }
}
then you can make an Example object using:
Example x = new Example("hello");
A method with no return type and the same name as the class is a constructor, and any parameters declared between the () must be provided between the () when an object of that class is made.
Storing data
If you have made a class as above and you want to have the objects hold on to the data you gave them when you constructed them, you need to tell them to store it in a field:
class Example {
    private String message;
    public Example(String s) {
        this.message = s;
        ...
    }
}
Private fields
Fields will usually be private, which means that no other classes can see what's in them. If you want to make the data available from the outside, you need to make an accessor method String getMessage() or provide a method for manipulating the data void appendToMessage(String s).

Plagiarism

Any work you hand in must be your own work. This includes not just the mechanical entry of the code but the thoughts and ideas behind it.

The School policy on Plagiarism (claiming other people's work as your own) is available from the course home page. If you have had help from someone else (other than course staff) you should state this in the report and at the relevant point in the code, describing the nature of the help received.