You are on page 1of 4

Problem 1: Car Rental Management System

The aim of this project is to design and implement a computerized Car Rental Management
System for a company called Cars.
The company rents two types of cars: standard and luxury cars. A car is identified by a car
identification number (int), a type (string), and a flag that indicates whether the car is currently
available or not.
Q1: Draw a class diagram to model the two different types of cars.
Solution 1: This is a simple solution, but may not be easily extensible. What happens if we
realize later that Luxury and Standard cars have their own attributes and behave
differently. Note that we can also use String for type, but it is better to use an enumeration
type to limit the value of type to “Standard” or “Luxury”

Car <<enumeration>>

id: Integer
Category
type: Category Standard
availability: Boolean Luxury

Solution 2: Use of generalization/specialization relationship. This is useful if types of cars


have their own attributes. It is also a good design if we want to add new car types, which
have different behaviors and attributes.

Car {abstract}
id: Integer
availability: Boolean

StandardCar LuxuryCar

1
The company distinguishes between two types of customers: regular customers and corporate
customers. A customer is identified by a customer number (int), name (string), address (string),
and a telephone number (string). A corporate customer has the following additional attributes:
The name (string) and address of the customer’s company (string).

Q2: Draw a class diagram to model the customers.

Solution 1:

Customer {abstract}
customerNumber: Integer
name: String
address: String
telephone: String
maximum

1..* 1
RegularCustomer CorporateCustomer Company
name: String
address: String

Furthermore, the customers have different types of privileges. A regular customer can only rent
standard cars for a maximum period of 20 days. Corporate customers can rent all types of cars
for a maximum period of 35 days.

Q3: How would you model the above requirements?

Regular customers
can only rent 0..1 1..*
standard cars for Customer {abstract} Car {abstract}
maxRentalPeriod =
20 days.
Corporate customers
customerNumber: Integer id: Integer
can rent standard name: String
availability: Boolean
and corporate cars address: String
for maxRentalPeriod
= 35 days telephone: String
maxRentalPeriod: Integer
StandardCar LuxuryCar

1..* 1
RegularCustomer CorporateCustomer Company
name: String
address: String

2
The company wants also to keep track of the rental and return dates to be able, for example, to
issue warnings for customers for which the rental is overdue or to know when a car is expected
to be returned.

Q4: Complete the diagram to model the above situation.

Regular customers
can only rent
standard cars for Rental
maxRentalPeriod =
20 days. rentalDate: Date
Corporate
customers can rent returnDate: Date
standard and
corporate cars for
maxRentalPeriod =
35 days

0..* 1..*
Customer {abstract} Car {abstract}
customerNumber: Integer id: Integer
name: String availability: Boolean
address: String
telephone: String
maxRentalPeriod: Integer
StandardCar LuxuryCar

1..* 1
RegularCustomer CorporateCustomer Company
name: String
address: String

<<enumeration>>
Category
Standard
Luxury

3
4

You might also like