Java Car Rental Application System

05/23 Java应用程序功能和项目 阅读 907 views 次 人气 0

Assessed Coursework Car Rental Application. This is a hard deadline. Work uploaded after this time (even by 1 second) will be flagged as late. Make sure you submit AT LEAST 15 minutes before this deadline. This coursework contributes 10% of the overall module mark.


The aim of this coursework is for you to practice the design principles covered in lectures. You will develop interfaces and classes to demonstrate that you have learned and understood module material, including:

a、appropriate overriding of Object class methods, including overriding toString and
providing a static valueOf method when appropriate

b、design of interface-based hierarchies, programming through interfaces and late binding

c、the use of factories to control instantiation of objects, including guaranteeing the instantiation of unique instances

d、defensive programming including the use of immutability

e、the use of appropriate interfaces and classes from the Collections framework

f、appropriate use of Javadocs to document your interfaces and classes

g、the use of testing

The coursework is not algorithmically challenging. The focus is on good design and good practice.

The coursework is not about development of an end-user application. You are developing interfaces and classes that could be used for the development of an application. You should not develop a graphical user interface or a command line interface.

They are not necessary and you will be given no credit for doing so. You should provide test cases for your interfaces and classes. To do this you can use the simple test framework and Assertions class provided.Alternatively, you can use the JUnit test framework facilities in Eclipse. In either case, you should submit both your solution and the classes that you use to test the solution.

Note the car rental system specified below is a deliberate simplification. It is not an accurate model of real world car rental. Your solution should correspond to the simplicity of the specification. You risk losing marks if you attempt to provide a more realistic model of car rental or provide a solution that is more complicated than necessary.

2、System overview

A car rental company needs a set of interfaces and classes to manage car rentals.
The company rents cars from its fleet of 30 small cars and 20 large cars. For this coursework,the significant difference between small cars and large cars is that they consume fuel at different rates (see Section 3).

When all cars of a particular type have been rented out, no more cars of that type can be issued by the company until one of the rented cars is returned.

A car can only be rented out to one person at a time. So, a car that is out for rent cannot be rented out again until after it has been returned and the existing rental contract terminated. Once a car has been returned, it is available for rent again. Another way of expressing this guarantee is that a car that is not rented or has been returned cannot be driven. That is, the status of any given car is either rented to one person (in which case it can be driven and the driver can add fuel to the car) or not rented (in which case it cannot).

A person can only rent out one car at a time.

The rental company needs to maintain a record of who has rented a given car (associating a person's driving licence details with the car they have rented). In addition, they need to be able to issue cars for rent and terminate rental contracts on return of cars. They also require information on cars currently out to rent. The following provides more detail on the required functionality:


This method returns the number of cars of the specified type that are available to rent.


This method returns a collection of all the cars currently rented out (if any)


Given a person's driving licence, this method returns the car they are currently renting (if any)

issueCar(drivingLicence, typeOfCar)

Given a person's driving licence and a specification of the type of car required (small or large), this method determines whether the person is eligible to rent a car of the specified type and, if there is a car available, issues a car of the specified type. The car must have a full tank of petrol at the start of the rental. The method associates the car with the person's driving licence (so that the company has a record of cars out for rent and the people renting them). If a car cannot be issued, the method returns an appropriate indication of the failure to issue a car. Note, this does not have to indicate why a car cannot be issued, it simply indicates that a car cannot be issued. The rules for determining whether or not a car can be issued are given below.


This method terminates the rental contract associated with the given driving licence. In effect, the driver is returning the car. The car is then available for rent by someone else. The method removes the record of the rental from the company's records (disassociating the car from the licence) and returns the amount of fuel in Litres required to fill the car's tank. The driver returning the car must either have returned the car with a full tank or will be liable for the number of Litres required to fill the tank. This terminateRental method is not responsible for managing charges for the required fuel. It just reports the amount of fuel required to fill the tank. This method changes the status of the returned car to not rented.Terminating a non-existent contract has no effect.

When issuing a car, the following rules must be observed.

a、the person renting the car must have a full driving licence

b、they cannot rent more than one car at a time

c、to rent a small car, they must be at least 21 years old and must have held their licence for at least 1 year

d、to rent a large car, they must be at least 25 years old and must have held their licence for at least 5 years

Note, you can assume that people renting cars have pre-paid vouchers for all rental costs except fuel. You are not concerned with the management of the vouchers.