Assignment 2
IMPORTANT: For more details about submission and demo, please read the section Submission Details and Demos at the end of this assignment specification.
Plagiarism is treated very seriously at RMIT. Plagiarism includes copying code directly from other students, internet or other resources without proper reference. Sometimes, students study and work on assignments together and submit similar files which may be regarded as plagiarism. Please note that you should always create your own assignment work even if you have very similar ideas.
Plagiarism-detection tools will be used for all submissions. Penalties may be applied in cases of plagiarism.
This assignment is designed to help you:
NOTE: Carefully read the following requirements. In addition, regularly follow the Canvas assignment discussion board for assignment related clarifications and discussion.
You must use the following packages to separate your code into sets of related classes and interfaces:
You can use sub-packages inside the packages shown above.
You are required to generate data for 6 rooms, including 3 standard rooms and 3 suites. At least one standard room and one suite having 2 completed rental records with random information such as customer ids, rent, return dates, rental fees and late fees that you are free to create as long as they are reasonable.
Each room must have a corresponding image. Image size should not be large (preferably from 100KB to 250KB). You must keep all images in a folder named images which is a direct sub-folder of your assignment project. If a room has no corresponding image, a default image with the phrase “No Image Available” should be used .
Creating Custom Exception Classes
In assignment 1, methods such as rent(…), returnRoom(…), performMaintenance(), completeMaintenance(..) have boolean as return types to indicate whether the corresponding operation is executed successfully or not. In assignment 2, you are required to modify all those methods so that all of them will return void instead of boolean and will throw custom exceptions. You are required to create custom exceptions such as RentException, ReturnException, MaintenanceException, InvalidIdException…. to represent various exceptional cases that can occur when those methods are executed. All of those custom exception types should allow appropriate error messages to be specified when exception objects are created.
Generating and Propagating Exception Objects
To use your custom exceptions effectively, you will need to look for areas in your program where you need to handle various cases such as when there is an invalid room id, or when a room or suite cannot be rented or returned, or when there is an invalid user input… Then you should generate appropriate exceptions and throw those exceptions back to the appropriate class to be handled.
Handling Exceptions
Those various exception objects should then be allowed to propagate back to the appropriate class (i.e. those exception should not be caught locally within the class that generates the exception).
All exceptions will need to be caught and handled in an appropriate manner by displaying a dialog box via the GUI to the user, showing the error message contained within the various exception objects that have been propagated up from the relevant method call.
Every time your program is executed and terminated, data will be read from and save to a database. For this assignment, you should use an embedded HSQLDB (shown in the lecture) or SQLite database. You must keep all database files in a folder named database which is a direct sub-folder of your assignment project.
You must create at least one table in your database to store all data of the CityLodge application including room and rental records. You are free to design the database, to chose appropriate tables, columns, data types that are suitable for storing data in your application.
NOTE: No need to store images directly in the database. Only image file names should be stored as text in the database. All images will still be kept in the images folder which is a direct sub-folder of your assignment project.