The University of Waikato Department of Computer Science Dr Robi Malik
COMPX102-20S
Object-Oriented Programming
Assignment 2
public enum VehicleType 9 I
The objective of this assignment isi
Exercise 1 (2 marks) can
r_SNumber
to practice how to maintain of a list of objects in C#.
Write a class RentalCar that holds the following information about each car in the fleet of a fictive car
rental company called “Waikato Driveaways”.
IThe registration plate number, a string of 6–8 capital letters and digits.
• The vehicle type, which can be Budget Hatchback, Economy Sedan, Minibus, Four-Wheel Drive, or
•
Campervan.
o vehiueType
• An indication whether or not the car is equipped with a GPS navigation system.
equipped
• An indication whether the car is powered by petrol or electric.
Detr.lic
• The rental rate per day, in dollars and cents.
Ǔ _rentaRl ates
• The expiry date of the car’s Warrant of Fitness (WOF). expiryDateOfWOE it
㒊
• An indication whether the car is presently lent out, and if so, the date when it is due to be returned.
ˇ
飝一
(Cars are not lent out initially, but this can be changed later.)
Your class should have instance variables and properties with read and write access for all the above items. You can choose how to represent dates, but they should be displayed and edited as combinations of day, month, and year. Also include a constructor to create cars that are not lent out, and a reasonable implementation of the ToString() method.
Exercise 2 (2 marks)
Oct 邋想巤羊篮内过期
Please write a program that initialises a list of rental cars, and displays all cars with all attributes in a ListBox. The fleet of Waikato Driveaways consists of at least twenty cars with at least three cars of each type. Also, there are at least three cars whose WOF is due to expire within seven days.
Note. It is a requirement that your program maintains a list of objects, not a list of strings or similar. Exercise 3 (12 marks) 9选6
Nine additional features of the Waikato Driveaways program are proposed below, each worth two marks. Please implement at least six of these to achieve the twelve marks available for this part of the assignment.
0a) Provide functionality to add new cars to the fleet. The user should be able to specify all attributes of a new car and insert it in the list, with the exception that new cars cannot already be lent out.
b) Provide functionality to edit cars. It should be possible to read all attributes of a selected car into text boxes or other controls, change the values in these controls, and click a button to write back the changed values into a selected car.
c) Provide functionality to delete cars. It should be possible to select one or more cars and delete all selected cars by a single invocation of this function.
d) Change your program so the vehicle type is not displayed as text but graphically using different icons or images.
e) Ensure that all registration plate numbers consist of 6–8 capital letters or digits, and prevent duplicate registration numbers. You can restrict your entry components to the allowed input, convert lower case characters to upper case, and/or display an error message when the user tries to create an invalid registration number.
Note. You can only get marks for this item of at least one of a) or b) is also implemented.
f) Instead of using rates entered by the user, calculate the rates as follows. Budget hatchbacks are $36.00 per day, economy sedans are $45.00, minibuses and four-wheel drive vehicles are $80.00, and campervans are $120.00. If the car has a GPS system, the rate is increased by $7.50 per day. If the car is electric, the rate is increased by $2.50 per day.
Hint. The rate becomes read-only with this feature, it can no longer be edited through a) or b) above. A good solution is to delete the rate instance variable from the RentalCar class, and calculate the rate in the property’s get method instead.
Hint. If b) is also implemented, the rate may need to be recalculated and redisplayed in the listbox after editing.
g) Provide functionality to lend out cars. The user should be able to select a car and specify the number of days it is to be rented for. The program should check whether the car is available—cars already lent out cannot be lent out a second time, and it is not possible to rent a car if its WOF is due to expire during the rental period. If the car is not available, an error message is displayed. If it is available, the return date is recorded, and an invoice is displayed showing the total amount charged to the customer for this rental.
h) Provide functionality to switch between two different views of the fleet. In Fleet Maintenance view, the rate is not displayed in the list box, and cars with WOF expiry date within seven days are highlighted. In Sales Desk view, the WOF expiry date is not displayed, and cars available for rent are highlighted. If implemented, cars can only be created, edited, or deleted from Fleet Maintenance view, and cars can only be lent out from Sales Desk view.
i) Make your application resizable. The form should adjust well when resized, with the list of cars always occupying as much space as possible. Do not waste any space on screen.
Exercise 4 (4 marks)
Like the previous assignment, your program will be assessed for its object-oriented design and program- ming style. Again, please write clean code with good identifier names, and follow naming conventions. Points of particular concern in this assignment are:
• Use appropriate data types.
• Make reasonable use of objects and methods. • Provide a well-designed user interface.
Submission
a) Please create a .zip archive containing all the files in your C# project directory and submit the archive through Moodle at
http://elearn.waikato.ac.nz/course/view.php?id=50476
b) Please complete your paper submission, consisting of:
• Your completed and signed cover sheet.
• A printout of the source code of all .cs files that you have edited. • A printed screenshot of your running program.
Please put the above items into the box marked COMPX 102S in front of room G 1.15 before the due date.
Verification
This assignment will be verified during the practical session on Wednesday 22 January 2020 at 13:00 in Computing Laboratory 3 (RG.10). If you cannot attend on 22 January, please arrange an alternative verification time with the lecturer before the assignment submission deadline.
Submission deadline: Monday, 20 January 2020, 11:00 A.M.