Class Diagram Exercises

Construct a UML class diagram for each of the following: 1. An international airport requires a system to keep track of flight details for customers. For each flight the system needs to store the flight number, destination, departure time, departure gate, airline and flight cost. Some flights are direct flights, i.e. they fly non-stop to the destination and some fly via another airport to their destination. We will call these flights indirect flights. In this case the flight stops at an airport en route to its destination to refuel. In the case of indirect flights information regarding the transit airport must also be stored. The flight cost is calculated to be the cost charged by the airline per customer plus a percentage of this amount (the profit_rate). In the case of indirect flights an additional levy must be added to this amount per customer in order to cover refuelling levies at the transit airport. Furthermore, on some flights additional passengers can board the plane at the transit airport. The system needs to keep track of whether boarding will take place at the transit airport or not. The system also needs to store details of the aircraft used for a flight. The aircraft make, model and capacity (number of passengers that it can carry), must be stored for each aircraft. Suppose that you are required to implement a system for a car dealership. The system needs to store information about each customer. This includes the customer’s ID number, name, address and contact number. The dealership sells both used and new cars. For all cars the registration number, year, make cost price and selling price must be stored. The dealership sells both new and used cars. Information regarding the previous owner, i.e. the contact person’s name and number, must also be stored for each used vehicle. The selling price of a car is calculated to the cost price plus a percentage markup of the cost price, i.e. selling price = cost price + cost price x markup percent. Suppose that you are required to implement a system for a technical college to keep track of student information. The information stored for each student includes the student’s number, name, address, phone number and fees due. The college has two types of students, namely, on-campus students and distance students. The matric points obtained by on-campus students must also be stored. Additional information that must be stored for distance students includes the city of the study centre they will report to and the duration over which they are completing the course. The fee for on-campus students is the sum of the course fee and a lab charge. In the case of distance students the fee is a sum of the subject cost plus a postage cost for notes. Each student enrols for a course. The details that are stored for each course is the name of the course, the subjects that need to be completed and the minimum duration of the course. NRB bank manages a number of customer accounts. A customer can have one of three types of accounts, namely, a current account, a savings account or a loan account. Details that need to be stored for each customer include the customers ID number, name, address and telephone number. Each account has an account number and balance. Money can be withdrawn from an account or deposited into the account. In the case of both the savings and cheque accounts a withdrawal results in the balance being decreased while in the case of a loan account the balance is increased. Similarly, a deposit results in the balance being increased for the cheque and savings accounts and decreased for the loan account. For each cheque account the customer’s profile, can be gold, silver or bronze. This information needs to be stored for each cheque account as accounts in these different categories have different benefits. Whenever a deposit is made into a savings account the customer earns interest on the updated 1

2.

3.

4.

while each pension instance specifies the pension number. 2 . In addition to this managers get a pension as a fringe benefit. A company requires a payroll system. amount and date of retirement. 5. All employees get a medical aid contribution. for a commission worker his/her flat salary. surname. loan limit. Each medical aid instance specifies the medical aid number. and an hourly worker. A commission worker earns a flat monthly salary as well as a percentage of the sales he/she makes for the month. Additional information needed for each loan account includes the duration of the loan in months. and the monthly instalments. sales percent and the sales made for the month. beneficiaries. Earnings must be calculated for each employee. A fixed wage is set per hour. A manager earns a fixed monthly salary. Additional information that must be stored for a manager is his/her monthly fixed salary. An hourly worker gets paid according to the number of hours worked.balance at a given rate. The company has three types of employees. a commission worker. The interest rate used needs to be stored for each savings account. Information that needs to be stored for each employee is the employee’s first name. namely. for an hourly worker the number of hours worked and the wage per piece. a manager. dependants. earnings and employee number. employee contribution and company contribution.