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".
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.
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.
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.
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.
Coaches want to know whether a lineup of players is valid to play at once. A lineup consists of seven players. A valid lineup includes a different player who can cover every position.
This is a difficult task, and if you have no idea where to start or get stuck you may like to consider moving on to extend the system in some other way instead.
try {
Scanner scanner = new Scanner(new File(filename));
...
scanner.close();
} catch (IOException e) {
UI.println("A file-reading error: " + e);
}
Scannersboolean hasNext()
checks whether there is another
"token" (essentially, a word) to
read.
String next()
returns that next token and
advances the Scanner to the end of
the word.
boolean hasNextInt()
checks whether there is an
integer to read in the file right
now.
int nextInt()
returns the next integer in the file,
if there is one, and reports an
error if there isn't.
String nextLine()
returns the remainder of the
line after the current
location.
ScannersString[] 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".
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.
class Example {
private String message;
public Example(String s) {
this.message = s;
...
}
}
String getMessage() or provide a method for
manipulating the data void appendToMessage(String s).
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.