UNSW Busines Schol
Schol of Information Systems and Technology Management
INFS1609 Assignment 3 (15%)
Revision Date Changes
1 21/09/2018 Initial release
Assignment Design
• This assignment is to be undertaken as an individual assignment
• This assignment is graded upon 15 marks and counts for 15% of your Overal Marks for
this course
• The assignment is due on Wednesday October 24, 2018, by 1200hrs (noon)
• The assignment must be submited electronicaly via Ed > Asesments. Please read the
submission requirements for each question carefuly.
• Test cases might be used to do a first-round marking of your code. You should try to run
your program on Ed to check if they pass the test cases. Test run your code as early as
possible because you might ned to make changes to your code.
• Please use the Ed discussion forum to discuss any issues related to this assignment.
• The readability of your code is one of the marking criteria. You should take care of your
coding style. and include coments in your code (wherever apropriate) to help explain it
Please make sure you have read the information about UNSW Business Schol protocols,
University policies, student responsibilities and education quality and suport on your Course
Outline: htps:/ww.business.unsw.edu.au/degres-courses/course-
outlines/archives/INFS1609-2018-S2#policies
If you have any questions about interpreting the assignment and its requirements, please make
use of the LICs consultation sessions. To avoid confusion and misunderstanding, we will not
be answering assignment-related questions over email.
business.unsw.edu.au
Part A: Car log bok (5%)
A rental company has a flet of vehicles. At the end of the vehicle’s life, the company wil take
out the log bok and input the folowing data into their system:
• Name
• Registration
• Colour
• Number of Trips
• Odometer readings of each trip
Design a Car class which contains the apropriate atributes to store al of the information,
you must create the apropriate geter, seter and constructor methods
Specific Requirements:
• A TestCar class is provided for you on Ed. This class is responsible for prompting the
user for input and displaying the output as specified below
§ Once al the required information is gathered, the test class should print out the name,
registration and colour, as per the sample outputs below
§ It should also print out the longest, shortest and average distance betwen odometer
readings (round the average to 2 decimal places)
• Al odometer readings wil be positive values and each value wil be greater than or equal
to the previous
• Odometer reading 0 represents the car’s initial odometer reading
• Please submit a Car.java and a TestCar.java
• TestCar.java wil be used for testing
3
business.unsw.edu.au
Sample (OUTPUTS in red, INPUTS in green):
Input name: Red Racer
Input registration: ABC123
Input colour: red
Input trips: 3
Odometer reading 0: 0
Odometer reading 1: 100
Odometer reading 2: 200
Odometer reading 3: 300
Red Racer | ABC123 | red
Longest distance travelled: 100
Shortest distance travelled: 100
Average distance travelled: 100
Input name: Swift Squeaker
Input registration: NBC374
Input colour: blue
Input trips: 0
Odometer reading 0: 123
Swift Squeaker | NBC374 | blue
Longest distance travelled: 0
Shortest distance travelled: 0
Average distance travelled: 0
4
business.unsw.edu.au
Part B: File System (7%)
You have ben asked by an Operating Systems developer to implement a basic File System.
The folowing types of files wil be stored in this file system:
• GenericFile with no format (file name, author)
• Word document (file name, author, pages, word count)
• Video (file name, author, duration in seconds, width, height)
Your File System is a bit quirky, the file size is calculated in the folowing way:
• GenericFile with no format = length of filename * length of author
• Word Document = length of author’s name * pages * word count
• Video = duration * width * height
5
business.unsw.edu.au
Task 1 (5%):
Using your knowledge of OP, design and implement the classes described above.
Specific Requirements:
• You should submit 5 Java files: GenericFile.java, Word.java, Video.java, FileSystem.java
and TestFileSystem.java
• Your FileSystem class is in charge of maintaining the objects (i.e. the GenericFiles). The
FileSystem constructor should take an int which specifies the number of files the
FileSystem can hold, and should provide the folowing publicly accessible methods:
public boolean createFile(String fileString);
The boolean will indicate whether the file was successfully created. Returns
false if the File System is full or if there is a duplicate file name
fileString will come in the following format:
GFILE||
WORD||||
VIDEO|||||
public boolean fileExists(String filename);
The boolean will indicate whether the file exists or not, returns true if it
does and false if it doesn’t
public void printFileSystem();
This should call the toString() method of each object and print it to the
screen in the same format as the fileString inputs
public void format();
This should empty the entire file system, restore it to a blank state
public String[] searchSize(int fileSize, int operation);
searchSize will return an array of filenames which match the criteria:
fileSize is the search parameter and operation is an int between 1-3
(1 is =, 2 is )
• We wil not use your TestFileSystem.java for testing, we wil cal FileSystem directly
Task 2 (2%):
Submit a design.txt document file containing your answer to the folowing question (20 words
maximum):
(a) Explain what is happening when you cal the toString() for each of the objects through
the printFileSystem()method
(b) Explain how you have implemented the searchSize() method and what aspect of OP
alows you to do this?
6
business.unsw.edu.au
Part C: Calculator (3%)
Design a Calculator class that functional like a conventional pocket calculator.
It is up to you how you implement the internal logic, however your program MUST have the
folowing publicly accessible methods:
public void clear();
public void pressNumber(int number);
public void pressOperation(int operation);
The possible values for pressNumber(int number) is 0 - 9
The possible values for pressOperation(int operation) is 1 - 5 where:
• 1 is division
• 2 is multiply
• 3 is minus
• 4 is plus
• 5 is equals
Specific Requirements:
• When a user presses multiple numbers in a continuous sequence the digits shift over by
one power
• When an operation is pressed we stop accepting input for the curent value
• This calculator is not a smart calculator, it does not folow BODMAS, it does every
operation as it comes into the calculator
• Your calculator should only print an output when the pressOperation(5) is caled
• If a division of 0 occurs, you should print EROR, al inputs should be ignored until
clear() is caled
• Al divisions that occur wil be round numbers
• If you press the equals sign multiple times, it should repeat the previous operation
• This calculator does not ned to handle the input of negative numbers
(i.e. pressOperation(3) pressNumber(6) to get -6 won’t be tested)
• Please use System.out.println() for al print operations
• Please submit a Calculator.java and TestCalculator.java. Please note, we do not use
your TestCalculator.java file for testing, this is only provided for you to test your
Calculator clas