INFS1609 Assignment 3 (15%)
UNSW Business School
School of Information Systems and Technology Management
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 Overall Marks for this course
· The assignment is due on Wednesday October 24, 2018, by 1200hrs (noon)
· The assignment must be submitted electronically via Ed > Assessments. Please read the submission requirements for each question carefully.
· 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 need 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 comments in your code (wherever appropriate) to help explain it
Please make sure you have read the information about UNSW Business School protocols, University policies, student responsibilities and education quality and support on your Course Outline: https://www.business.unsw.edu.au/degrees-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.
Part A: Car log book (5%)
A rental company has a fleet of vehicles. At the end of the vehicle’s life, the company will take out the log book and input the following data into their system:
· Name
· Registration
· Colour
· Number of Trips
· Odometer readings of each trip
Design a Car class which contains the appropriate attributes to store all of the information, you must create the appropriate getter, setter 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 all 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 between odometer readings (round the average to 2 decimal places)
· All odometer readings will be positive values and each value will 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 will be used for testing
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
Part B: File System (7%)
You have been asked by an Operating Systems developer to implement a basic File System. The following types of files will 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 following 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
Task 1 (5%):
Using your knowledge of OOP, 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 following 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 < and 3 is >)
· We will not use your TestFileSystem.java for testing, we will call FileSystem directly Task 2 (2%):
Submit a design.txt document file containing your answer to the following question (200 words maximum):
(a) Explain what is happening when you call the toString() for each of the objects through the printFileSystem()method
(b) Explain how you have implemented the searchSize() method and what aspect of OOP allows you to do this?
Part C: Calculator (3%)
Design a Calculator class that functional like a conventional pocket calculator.
public void clear(); public void pressNumber(int number); public void pressOperation(int operation);
It is up to you how you implement the internal logic, however your program MUST have the following publicly accessible methods:
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 current value
· This calculator is not a smart calculator, it does not follow BODMAS, it does every operation as it comes into the calculator
· Your calculator should only print an output when the pressOperation(5) is called
· If a division of 0 occurs, you should print ERROR, all inputs should be ignored until
clear() is called
· All divisions that occur will be round numbers
· If you press the equals sign multiple times, it should repeat the previous operation
· This calculator does not need 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 all 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 class
Sample:
Operation | Value | Output |
pressNumber(1) pressNumber(2) | 12 | |
pressNumber(3) | 3 | |
pressOperation(4) | + | |
pressNumber(1) | 1 | |
pressNumber(4) | 4 | |
pressOperation(5) | = 17 | 17 |
pressOperation(4) | + | |
pressNumber(1) | 1 | |
pressOperation(5) | = 18 | 18 |
pressNumber(3) | 3 | |
pressOpertaion(3) | – | |
pressNumber(5) | 5 | |
pressOperation(5) | = -2 | -2 |
pressNumber(1) | 1 | |
pressOperation(1) | / | |
pressNumber(0) | 0 | |
pressOperation(5) | = | ERROR |
pressNumber(7) | 7 ignored | |
clear() | ||
pressNumber(8) | 8 | |
pressNumber(7) | 7 | |
pressOperation(4) | + | |
pressNumber(5) | 5 | |
pressOperation(5) | = 12 | 12 |
pressOperation(5) | 12 + 5 = 17 | 17 |
pressOperation(5) | 17 + 5 = 22 | 22 |
pressNumber(7) clear() pressOperation(5) | 7 |
0 |
pressNumber(7) | 7 | |
pressOperation(4) | + | |
pressNumber(5) | 5 | |
pressOperation(4) | + | |
pressNumber(5) | 5 | |
pressOperation(5) | = 17 | 17 |