Professional Documents
Culture Documents
Assessment 2: Real-Time Programming Assignment
Assessment 2: Real-Time Programming Assignment
Objectives
This is an individual assignment. Students are not permitted to work in a group when writing this
assignment.
Submission Guidelines
Your assignment submission should be typed, not written/drawn by hand.
Submit the electronic copy of your assignment through the subject LMS.
Submission after the deadline will incur a penalty of 5% of the available assignment mark per day
capped at 5 days. No assignment will be accepted after 5 days. If you have encountered difficulties
that lead to late submission or no submission, you should apply for special consideration.
1. Access the Java collections framework in the Java standard library (API) and use the
provided generic ArrayList class to solve problems.
2. Use input and output streams provided in the Java standard library (API) to code programs
that manipulate text and binary files
3. Explain the object-oriented concepts of inheritance and polymorphism and apply them to
solve problems in Java
The real-time programming assignment runs according to this schedule on the nominated day:
Time Description
6:15pm Real-time programming assignment automatically opens on the
LMS.
6:15pm to 6:30pm Reading time (15 minutes).
6:30pm to 9:30pm Writing time (3 hours).
9:30pm to 9:45pm Submission to LMS (15 minutes).
9:45pm Real-time programming assignment automatically closes on the
LMS.
If you finish any activity above in the schedule early, you are permitted to move onto the next step
immediately.
Note that it is not possible to pause the real-time programming assignment and resume later.
Importantly the real-time programming assignment is strictly limited to one attempt only.
Before starting the real-time programming assignment, you should familiarise yourself with the
submission instructions under the “Submission” heading below.
If you have any questions about the real-time programming assignment, make sure you submit a
support request before you start.
Further information is provided in the assessment 2 overview webinar and the date is also in your
calendar.
a) Define an ArrayList<String> with the following names: “Alice”, “Bob”, “Chelsie”, “Dave”,
“Edward”.
b) Add “Francene” to the end of the list.
c) Add “George” to the start of the list.
d) Print the index of “Bob”.
e) Print the name of the fifth person.
f) Remove “Alice”.
g) Remove the third person.
h) Print the names of all people using the enhanced for-loop.
[18 marks]
Create a new NetBeans 8.2 Java project called Part2 and add the following starter code in a class
called FootballScores:
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.Random;
FootballGame
- roundNumber : int
- homeGoals : int
- homeBehinds : int
- awayGoals : int
- awayBehinds : int
+ FootballGame ( roundNumber : int,
homeGoals : int, homeBehinds : int,
awayGoals : int, awayBehinds : int )
+ summarize () : String
+ toString() : String
• summarize(): Calculates the winner of the game. Prints a message reporting whether the
home team won, lost, or tied the game. Example output formats:
o Round 1: Home team won 26 points to 20.
o Round 2: Home team lost 8 points to 33.
o Round 3: Match was tied 42 points each.
• toString(): Gives a comma separated values (CSV) representation of the football game
details:
o roundNumber,homeGoals,homeBehinds,awayGoals,awayBehinds
[14 marks]
Question 3 (9 marks)
Complete the body of the writeTextScores() method from the FootballScores class provided in the
starter code. This method will randomly generate the scores of NUM_ROUNDS football games.
Each goal and behind score is a randomly generated number that must be at least 0 and less than
MAX_SHOTS. The scores are written to the file represented by the TEXT_FILE constant. Each line
of the file will be in the format from the toString() method in the FootballGame class.
[9 marks]
Question 4 (10 marks)
Complete the body of the printTextScores() method from the FootballScores class provided in the
starter code. This method reads the scores from the TEXT_FILE file for one game at a time. For
each game, the data is converted back to a FootballGame object and the result of the game is
printed to the console using the summarise() method. (Hint: You can use the split() method of the
String class to convert CSV data to tokens.)
[10 marks]
Here are the registration fees that are charged for an annual registration:
Vehicle RegistrationTester
Car Motorcycle
Create a new NetBeans 8.2 Java project called Part3 and complete the following questions.
When you are finished your real-time programming assignment, close NetBeans, and copy the
project folders into a new empty folder called XXX_cse1iox_programming_test, where XXX is your
Student ID. Zip the folder as XXX_cse1iox_programming_test.zip, and submit to the LMS.
(End of exam.)