CSE1OFX Object Oriented Programming Fundamentals
Assessment 3 – Car Rental Assessment
Objectives
Discuss the concepts of classes, objects, encapsulation and inheritance relating to object-oriented programming paradigm and apply them to solve a real-world problem.
Analyse mathematical, scientific and other types of problems and design logical solutions for each, suitable for implementing as a computer program.
Use an object-oriented programming language, and associated class libraries, to develop object-oriented programs.
Use a development environment to develop, test, and debug programs that solve a given problem.
Design and develop a test plan to ensure that a given programming solution works as anticipated in both expected and unexpected scenarios.
Construct appropriate diagrams and textual descriptions to communicate the static structure and the dynamic behaviour of any object-oriented programming solution. This is an INDIVIDUAL assignment. Students are not permitted to work in a group when writing this assignment. Copying, Plagiarism This is an individual assignment. Students are not permitted to work in a group when writing this assignment. Plagiarism is the submission of another person’s work in a manner that gives the impression that the work is their own. La Trobe University treats plagiarism seriously. When detected, penalties are strictly imposed. Further information can be found on http://www.latrobe.edu.au/students/academicintegrity/explanation/plagiarism Submission Guidelines • Your assignment submission should be typed, not written/drawn by hand. • Submit the electronic copy of your assignment through the subject Learning Portal. • Submission after the deadline will incur a penalty of 5% of the available marks for that task 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.
Table of Contents
CSE1OFX Object Oriented Programming Fundamentals ................................................1
Assessment 3 – Car Rental ..............................................................................................1
Assessment Objectives ....................................................................................................1
Copying, Plagiarism .........................................................................................................1
Submission Guidelines .....................................................................................................1
Summary ..........................................................................................................................3
Scenario ...........................................................................................................................3
Solution design ................................................................................................................3
Classes ........................................................................................................................... 3
Functionality..................................................................................................................... 4
Example of Expected Implementation ............................................................................ 5
Assessment Tasks .......................................................................................................... 7
Task overview ................................................................................................................. 7
Tasks 1-2: UML Diagram ................................................................................................ 7
Task 1: UML Classes ...................................................................................................... 7
Task 2: UML Class Relationships ................................................................................... 7
Tasks 3 - 10: Implementation ......................................................................................... 7
Task 11: Test scenario .................................................................................................. 12
Task 12: Testing the code.............................................................................................. 12
Task 13: Coding Conventions ....................................................................................... 13
Submitting your assignment ......................................................................................... 13
Assessment marking criteria ........................................................................................ 14
Summary
A car hire company is an organisation that rents out cars and other vehicles to customers over a set period, usually ranging from a couple of days to a couple of weeks.
Hiring a car is a common practice for those who have taken a plane to a destination and wish to be able to manage their own transport needs on the ground. It is also becoming increasingly common for residents of a town to avoid the ongoing expenses of owning their own car, and to simply hire a car locally whenever they need one.
In this assessment task you will create your own Java object-oriented console based (command line) program that will allow a customer to make a partial booking of a vehicle through a car hire company. The car booking system will be implemented with text prompts, standard output, and ASCII-art drawing where required. You will also need to read data from a file in CSV format.
It is strongly recommended that you read through the entire assessment before commencing any of the tasks.
Scenario
Carrington Cars has been a player in the car rental market for many years. The organisation prides itself on customer service and has numerous rental centres in convenient locations around the city of Melbart. The organisation has recently seen a significant increase in the number of customers arriving at their centres without securing a booking online. In many cases the staff at centres are overwhelmed, leading to delays in customer support. To streamline the customer service experience Carrington wish for customers to be able to make a partial booking onsite using an in-store consolebased system. This partial booking is then finalised by Carrington staff in person with the customer when they become available.
Solution design
Classes
It is expected that the solution will comprise eight classes as outlined below:
Functionality
It is expected that your solution will have the following functionality:
• The user should be presented with an initial welcome message.
• Details on the cars to be hired (including daily rates) are to be retrieved from a file named ‘carlist.csv’ (provided) and displayed in a tabular format. An appropriate error message should be displayed if the file is unable to be retrieved.
• The program should allow the user to enter a selection to proceed or exit from the program i.e. user to be given the following options:
o Make a booking
o Exit
• The program should allow a user to select a car that they would like from the list
• The program should include prompts for the user to enter start and end dates of a hire. These should be:
o A prompt for the year
o A prompt for the month
o A prompt for the day
• The program should capture the following details from a user:
o Name
o Email
o Address
• There are two types of cars:
o Standard cars (as represented in the Car class). Standard cars have a base daily rate of hire.
o Premium cars (as represented in the PremiumCar class, an extension of the Car class). On top of the daily rate, there is an extra cost with the hire of premium cars that being:
The need to pay insurance on the hire of a premium car. Insurance is calculated as 5% of the daily rate.
• The program should calculate the cost of the hire dependent upon:
o Daily rate of hire
o Number of days of hire
o Extra costs for premium cars (as outlined above)
• Once all details have been collected from the user, the following information should be displayed to the user as a summary:
o Customer details
o Booking confirmation
o Car hired
o Start and end dates of hire
o Number of days of hire
o Rate per day
o Total cost of hire
Example of Expected Implementation
Refer to Figure 1 for an example of how the user interface might be presented
Figure 1 shows the following functionality in action:
• Display to user of the list of cars available and the total records displayed (drawn from information provided in carlist.csv file)
• User given initial menu to make a booking or exit the program
• User able to select their choice of car (with informative error message if invalid selection is made)
• User able to enter the start and end dates of their booking
• User able to enter relevant personal details (name and contact information)
• Display of summary of booking details
• User able to continue with another booking or exit the program
Assessment Tasks
Task overview
The first two tasks are focused on the development of a UML diagram while the remaining tasks are based on implementing and testing the program.
It is recommended that you read through the information and requirements of all tasks below prior to commencing any work on your project, and that you complete the structure of your UML diagram before proceeding with later tasks.
Code in your solution should abide by the following best practices:
• Error handling for user input.
• Consistent code indentation with one level of indentation per block.
• Code commenting for each class, all methods, and inline comments
• Naming conventions adhered to.
• Reasonable code line lengths.
It is also recommended that you review the assessment rubric at the end of this document for a better understanding of the basis on which your submission will be marked.
Tasks 1-2: UML Diagram
Create a complete UML class diagram using Visio for the Car Rental program.
Task 1: UML Classes
Represent classes on the UML diagram based on the information provided in the class descriptions in Tasks 3-10 below
Task 2: UML Class Relationships
Represent the relationships between classes on the UML diagram including multiplicities (where required) and relationship names.
Tasks 3 - 10: Implementation
Tasks 3-10 describe the classes that together make up the overall program.
Implementation tips for Tasks 3-10
Try to break down the logic in the assessment into small sections. In general, you should focus on implementing, testing and running small sections of the assessment at a time. This ensures that building blocks for your assessment are sound. Also, if you make any errors in your code, they will be more easily identified and rectified.
If you find that any of the methods are particularly long, you are welcome to introduce additional ‘helper’ methods to break up your work.
Make sure that you lodge a support request if you would like any guidance.
Task 3: MenuDisplay Class
This class manages the retrieval of available cars from a CSV file and displays them to the user.
MenuDisplay Constructors and methods:
Name
Return value
Input parameters
Description
displayCarList
int
None
Displays list of cars to user in tabular format and returns the number of cars available. Refer to Figure 1.
getSelection
int
None
Prompt to make booking or exit from the system.
Task 4: CarAndBookingDates Class
This class manages user selections of the car be hired, and the dates they would like to hire.
CarAndBookingDates Instance variables:
Name
Data Type
Description
year
int
Contains the year value
month
int
Contains the month value
day
int
Contains the day value
CarAndBookingDates Constructors and methods:
Name
Return value
Input parameters
Description
CarAndBookingDates
n/a
None
Constructor to initialise instance variables with default values
carSelection
int
int carsAvailable
Prompts user for entry of a Car ID number and validates based on the records available. If the car number selected is not found, appropriate error message to be displayed and retakes the input until a valid selection is made.
Returns a valid selection.
carsAvailable: the input parameter contains the total record retrieved from the CSV file.
getCarBookingDateFull
LocalDate
None
Calls the Year, Month and Day of booking date input methods.
Method collates the date inputs and returns as a LocalDate format.
promptForYear
int
None
User prompt for year of date
promptForMonth
int
None
User prompt for month of date
promptForDay
int
None
User prompt for day of date
validateYearString
boolean
String year
Check if year value is valid
validateMonthString
boolean
String month
Check if month value is valid
validateDayString
boolean
String day
Check if day value is valid
Task 5: CarBooking Class
This class does all the work of calculating duration and cost of the hire of a car.
CarBooking Instance variables:
Name
Data Type
Description
startDate
LocalDate
Start Date of Booking
endDate
LocalDate
End date of Booking
carNumber
int
ID number of car
totalDays
long
Duration of booking in days
newRate
double
Calculated rate of booking
cost
double
Total cost of booking
car
Car
Car that is associated with booking
CarBooking Constructors and methods:
Name
Return value
Input parameters
Description
CarBooking
n/a
LocalDate startDate, LocalDate endDate, int carNumber
Constructor to initialise instance variables.
makeBooking
void
None
The method reads the CSV file: implement them with the try/catch mechanism and print an error message and exit when caught. And
Car number selected would be required to retrieve the details and store them in an array.
Based on the car type determine if a new rate is required or the existing rate to total calculate cost.
Calls the calculateTotalDays and calculateCost methods.
calculateTotalDays
void
None
Calculates the difference in days between the start date and the end date of the booking
calculateCost
void
double newRate long totalDays
Sets the cost of a booking based on the rate by the number of days
getCost
double
None
Accessor method for ‘cost’
getStartDate
Date
None
Accessor method for ‘startDate’
getEndDate
Date
None
Accessor method for ‘endDate’
getTotalDays
long
None
Accessor method for ‘totalDays’
getCarNumber
Int
None
Accessor method for ‘carNumber’
getNewRate
double
None
Accessor method for ‘newRate’
getCarName
String
None
Accessor method for ‘carName’
Task 6: Car Class
This class holds information related to individual cars that are available for hire.
Car Instance variables:
Name
Data Type
Description
carRate
double
The base cost of hiring a car
carName
String
The name of the type of car
Car Constructors and methods:
Name
Return value
Input parameters
Description
Car
n/a
String carName double carRate
Constructor to initialise instance variables.
getCarRate
double
None
Accessor method for ‘carRate’
getCarName
String
None
Accessor method for ‘carName’
Task 7: PremiumCar Class
This class is an extension of the Car class. As such, all existing functionality is automatically inherited. This documentation lists additions and differences only.
PremiumCar Instance variables:
Name
Data Type
Description
INSURANCERATE
double
Constant representing the percentage rate of insurance: 0.05
PremiumCar Constructors and methods:
Name
Return value
Input parameters
Description
PremiumCar
n/a
double carRate String carName
Constructor to initialise instance variables.
getCarRate
double
None
Override method of Car class
Task 8: Customer Class
This class manages the details of the customer looking to hire a car.
Customer Instance variables:
Name
Data Type
Description
customerName
String
Name of the customer
customerEmail
String
Email address of the customer
customerAddress
String
Address of the customer
Customer Constructors and methods:
Name
Return value
Input parameters
Description
Customer
n/a
String customerName
String customerEmail
String customerAddress
Constructor to initialise instance variables.
getCustomerName
String
None
Accessor method for
‘customerName’
getCustomerEmail
String
None
Accessor method for
‘customerEmail’
getCustomerAddress
String
None
Accessor method for
‘customerAddress’
Task 9: PrintBookingDetails Class
This class displays details of a finalised booking to the user.
PrintBookingDetails Constructors and methods:
Name
Return value
Input parameters
Description
printBookingDetails
void
CarBooking carBooking Customer customer
Displays the details of booking to customer or user
Task 10: CarRentalTester Class
This is the overall entry point for the program and has the following functionality:
• Controlling access to the main menu, customer details and car booking information.
• The main method invokes and captures the values from: displayCarList(), carSelection(…), getCarBookingDateFull(). Values captured are passed as input parameter to methods and objects instantiated.
• Other necessary methods, such as makeBooking() and printBookingDetails(…) are also invoked from the driver class. Apply necessary iteration to loop the program.
CarRentalTester Instance variables:
Name
Data Type
Description
menu
MenuDisplay
Instance of the MenuDisplay class
customer
Customer
Instance of the Customer class
carBooking
CarBooking
Instance of the CarBooking class
carAndBookingDates
CarAndBookingDates
Instance of the CarAndBookingDates class
CarRentalTester Constructors and methods:
Name
Return value
Input parameters
Description
main
void
None
Entry point for program.
Task 11: Test scenario
Download and fill in the Test_Case_Template.docx from the learning portal. The template will be used for testing the date input.
The test scenario should cover the following tests that generate valid outcomes:
1. The duration for hire is greater than zero
2. The duration for hire is 30 days or less for the month of November
…and the following test cases that generate invalid outcomes:
3. The duration for hire is less than zero
4. The duration for hire is 32 days or more for the month of January
5. The duration for hire is 31 days or more for the month of November.
Task 12: Testing the code
After you have finished writing your code, test it by performing the following tasks. Your response must include a screenshot of the output for each of the following. These tasks have a combination of valid and invalid tests. Note that that an invalid entry should catch the validation applied.
1. Test for exception handling with file retrieval through running code after updating file name as follows:
File Name: “cark.csv”
Take a screenshot of the output.
2. Run the code with the following inputs to validate the car number selection:
Car number: 7
If the car selected is not the one of the available cars as displayed, the program should request that the user re-enter the car selection.
Take a screenshot of the output
3. Run the code with the following inputs to verify end date is not before start date: Car number: 2
Start Date: Year: 2020, Month: 5, Day: 1
End Date: Year: 2020, Month: 4, Day: 13
If the end date is before the start date, the program should request that user re-enter information
Take a screenshot of the output
© Didasko 2019. All rights reserved. 13
4. Run the code with the following inputs to make a booking for premium car:
Car number: 1
Start Date: Year: 2020, Month: 10, Day: 5
End Date: Year: 2020, Month: 10, Day: 15
Customer details: for customer details use your name, email and address. Take a screenshot of the output
5. Run the code with the following inputs to make a booking for standard car:
Car number: 5
Start Date: Year – 2020, Month – 9, Day – 1
End Date: Year – 2020, Month – 9, Day – 18
Customer details: for customer details use your name, email and address.
Take a screenshot of the output
Task 13: Coding Conventions
When coding your solution the following coding conventions must be followed.
a) Commenting: Add a class header comment, method header comments, and inline comments where required.
b) Indentation: Consistently indent your code by one level per block. (A good guideline is the
NetBeans default of 4 spaces per block.)
c) Naming conventions: Use TitleCase for class names, camelCase for variables and UPPER_CASE for constants.
d) Line lengths: Do not exceed the 80 characters per line guideline.
Submitting your assignment
When you have completed your answers, submit the assessment on the Learning Portal. You should submit the following:
Task number
File name
Description
Tasks 1-2
xxx_cse1ofx_assessment3_uml.vsdx
Visio UML diagram
Tasks 3-10
xxx_cse1ofx_assessment3_code.zip
Zipped NetBeans project
Task 11
xxx_cse1ofx_assessment3_testScenario.docx
Test scenario
Task 12
xxx_cse1ofx_assessment3_ screenshots.docx
Testing the code
Notes:
• Replace the “xxx” placeholders with your Student ID.
• The Zip file mentioned above is a compressed version of your code solution folder.
Assessment marking criteria
The complete marking rubric is given below. During marking, one option will be selected per row and additional feedback will be given where necessary.
Task 1a: UML diagram classes (All classes)
Classes have not been satisfactorily represented
0 points
There are a significant number of errors in the representation of classes
1 point
There are a small number of errors in the in the representation of classes
2 points
All classes have been satisfactorily represented
3 points
Task 1b: UML diagram constants (in PremiumCar class)
Constants have not been represented correctly.
0 points
There is a minor error with how the constants have been represented
0.5 points
Constants have been represented correctly.
1 point
Task 1c: UML diagram instance variables (Car, CarBooking, Customer, CarRentalTester classes
Instance variables have not been represented correctly
0 points
There are minor errors with how the instance variables have been represented
1 point
Instance variables have been represented correctly 2 points
Task 1d: UML diagram methods (All classes)
0 method sets satisfactory.
0 points
There are a significant number of errors in the representation of methods
1 point
There are a small number of errors in the in the representation of methods
2 points
All methods have been satisfactorily represented
3 points
Task 1e: UML diagram constructors (Car, Premium Car, CarAndBookingDates classes)
Instance variables have not been represented correctly
0 points
There are minor errors with how the constructors have been represented
1 point
Constructors have been represented correctly 2 points
Task 1f: UML diagram visibility modifiers (All classes)
Visibility modifiers are incorrect.
0 points
Visibility modifiers are partly correct.
0.5 points
Visibility modifiers are correct.
1 point
Task 2a: UML diagram relationships
Relationships are not satisfactorily represented.
0 points
There are a significant number of errors in the representation of relationships
1 point
There are a small number of errors in the in the representation of relationships
2 points
All relationships have been satisfactorily represented
3 points
Task 2b: UML diagram relationship multiplicities (where required)
Relationships are not satisfactorily represented.
0 points
There are a small number of errors in the representation of relationships
0.5 point
All relationships have been satisfactorily represented
1 point
Task 2c: UML diagram relationship names
Relationships are not satisfactorily named.
0 points
There are a small number of errors in the naming of relationships
1 point
All relationships have been satisfactorily named
2 points
Task 3a:
MenuDisplay class diplayCarList method
Solution is incorrect.
0 points
Solution is partly correct. 1 point
Solution is correct. 2 points
Task 3b:
MenuDisplay class
getSelection method
Solution is incorrect.
0 points
Solution is partly correct. 1 point
Solution is correct. 2 points
Task 4a:
CarAndBookingDat
es class constructor
Constructor is incorrect.
0 points
Constructor is partly correct. Constructor is correct.
0.5 points 1 point
Task 4b:
CarAndBookingDat es carSelection method
Solution is incorrect.
0 points
Solution is partly correct. 1 point
Solution is correct. 2 points
Task 4c:
CarAndBookingDat
es
getCarBookingDate
Full method
Solution is incorrect.
0 points
Solution is partly correct. 1 point
Solution is correct. 2 points
Task 4d:
CarAndBookingDat es promptForYear method
Solution is incorrect.
0 points
Solution is partly correct. 1 point
Solution is correct. 2 points
Task 4e:
CarAndBookingDat es promptForMonth method
Solution is incorrect.
0 points
Solution is partly correct. 1 point
Solution is correct. 2 points
Task 4f:
CarAndBookingDat es promptForDay method
Solution is incorrect.
0 points
Solution is partly correct. 1 point
Solution is correct. 2 points
Task 4g:
CarAndBookingDat
es
validateYearString method
Solution is incorrect.
0 points
Solution is partly correct. 1 point
Solution is correct. 2 points
Task 4h:
CarAndBookingDat
es validateMonthString method
Solution is incorrect.
0 points
Solution is partly correct. 1 point
Solution is correct. 2 points
Task 4i:
CarAndBookingDat
es
validateDayString method
Solution is incorrect.
0 points
Solution is partly correct. 1 point
Solution is correct. 2 points
Task 5a
CarBooking class instance variables
Instance variables are incorrect.
0 points
Some instance variables are correct 0.5 points
All instance variables are correct. 1 point
Task 5b: CarBooking class small methods:
getCost getStartDate getEndDate getTotalDays getCarNumber getNewRate getCarName
Small methods are incorrect. 0 points
Small methods are partly correct. 1 point
Small methods are correct. 2 points
Task 5c:
CarBooking class makeBooking method
Solution is incorrect.
0 points
Solution is partly correct. 1 point
Solution is correct. 2 points
Task 5d:
CarBooking class calculateCost method
Solution is incorrect.
0 points
Solution is partly correct. 1 point
Solution is correct. 2 points
Task 6a:
Car class instance variables
Instance variables are incorrect.
0 points
Instance variables are partly correct 0.5 points
Instance variables are correct. 1 point
Task 6b:
Car class
constructor
Constructor is incorrect.
0 points
Constructor is partly correct.
0.5 points
Constructor is correct. 1 point
Task 6c:
Car class small methods: getCarRate setCarRate getCarName setCarName
Small methods are incorrect. 0 points
Small methods are partly correct. 1 point
Small methods are correct. 2 points
Task 7a:
PremiumCar constants
Constants are incorrect.
0 points
Constants are partly correct
0.5 points
Constants are correct. 1 point
Task 7b:
PremiumCar class constructor
Constructor is incorrect.
0 points
Constructor is partly correct. Constructor is correct.
0.5 points 1 point
Task 7c
PremiumCar class override method
Override method is incorrect. 0 points
Override method is partly correct. 1 point
Override method is correct. 2 points
Task 8a Customer class instance
variables
Instance variables are incorrect.
0 points
Some instance variables are correct 0.5 points
All instance variables are correct. 1 point
Task 8b: Customer class constructor
Constructor is incorrect.
0 points
Constructor is partly correct. 1 point
Constructor is correct. 2 points
Task 8c: Customer class small methods: getCustomerName getCustomerEmail getCustomerAddress
Small methods are incorrect. 0 points
Small methods are partly correct. 1 point
Small methods are correct. 2 points
Task 9:
PrintBookingDetails class
printBookingDetails method
Solution is incorrect.
0 points
Solution is partly correct. 1 point
Solution is correct. 2 points
Task 10a
CarRentalTester
class instance
variables
Solution is incorrect.
0 points
Solution is partly correct. 1 point
Solution is correct. 2 points
Task 10b
CarRentalTester main method
Solution is incorrect.
0 points
Solution is mostly Solution is partly Solution is mostly Solution is correct.
incorrect. correct. correct. 4 points 1 point 2 points 3 points
Task 11a: Test scenario 1 –
Description Field
Test scenario description field is incomplete or
inappropriate
Test scenario description field is
appropriate.
0.5 points 0 points
Task 11b: Test scenario 1 – Other Fields
Other test scenario fields
Other test scenario fields All other test scenario fields
partially completed as incomplete or inappropriate completed as expected.
expected.
0 points 1 point 0.5 points
Task 11c: Test scenario 1 –
Duration is greater than zero
Test Case is incomplete or inappropriate 0 points
Test case is correct.
0.5 points
Task 11d: Test scenario 1 –
Duration is less than
30 for month of
November
Test Case is incomplete or inappropriate 0 points
Test case is correct.
0.5 points
Task 11e: Test scenario 1 – Day is less than zero
Test Case is incomplete or inappropriate 0 points
Test case is correct.
0.5 points
Task 11f: Test scenario 1 –
Duration is 32 or more for month of
January
Test Case is incomplete or inappropriate 0 points
Test case is correct.
0.5 points
Task 11g: Test scenario 1 –
Duration is 31 or more for month of
November
Test Case is incomplete or inappropriate 0 points
Test case is correct.
0.5 points
Task 12: Testing the code
2 tests are
Unsatisfactory 0 1 test is correct
correct points 0.5 points 1 point
3 tests are 4 tests are correct correct 1.5 points 2 points
5 tests are correct 3 points
no penalty)
Total: 80 points
Task 13a: Code
indentation
Code indentation was excellent Code indentation was Code indentation was fair and and met the standard with
unsatisfactory and needs work. needs some work. consistent indentation of one
0 points 1 point level per block.
2 points
Task 13b: Code commenting
Code commenting was excellent and met the standard Code commenting was Code commenting was fair and with class header comments, unsatisfactory and needs work. needs some work. method header comments, and
0 points 1 point some inline comments where
appropriate.ts. 2 points
Task 13c: Naming conventions
Naming conventions did not meet expected standards. 0 points
Naming conventions were excellent and met the standard with TitleCase for class names, camelCase for variables and UPPER_CASE for constants.
1 point
Task 13d: Code line lengths
Line lengths did not meet guidelines. 0 points
Line lengths were excellent and did not exceed the 80 characters per line guideline.
1 point
Submission timeliness
5 days late
(25% penalty)
-20 points
4 days late 3 days late 2 days late 1 day late On time
(20% penalty) (15% penalty) (10% penalty) (5% penalty) (
-16 points -12 points -8 points -4 points 0 points
Task 1a: UML diagram classes (All classes)
There are a significant There are a small
Classes have not All classes have been
number of errors in the number of errors in the been satisfactorily satisfactorily
representation of in the representation of represented represented
classes classes
0 points 3 points 1 point 2 points
Download the solution from given Link- 100% accurate
Comentários