Class Diagram

2
1 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. 2. 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. 3. 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. 4. 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

Transcript of Class Diagram

Page 1: Class Diagram

1

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-stopto the destination and some fly via another airport to their destination. We will call theseflights indirect flights. In this case the flight stops at an airport en route to its destinationto refuel. In the case of indirect flights information regarding the transit airport must alsobe stored. The flight cost is calculated to be the cost charged by the airline percustomer plus a percentage of this amount (the profit_rate). In the case of indirectflights an additional levy must be added to this amount per customer in order to coverrefuelling levies at the transit airport. Furthermore, on some flights additionalpassengers can board the plane at the transit airport. The system needs to keep trackof whether boarding will take place at the transit airport or not. The system also needsto 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.

2. Suppose that you are required to implement a system for a car dealership. The systemneeds to store information about each customer. This includes the customer’s IDnumber, name, address and contact number. The dealership sells both used and newcars. For all cars the registration number, year, make cost price and selling price mustbe stored. The dealership sells both new and used cars. Information regarding theprevious owner, i.e. the contact person’s name and number, must also be stored foreach used vehicle. The selling price of a car is calculated to the cost price plus apercentage markup of the cost price, i.e. selling price = cost price + cost price x markuppercent.

3. Suppose that you are required to implement a system for a technical college to keeptrack of student information. The information stored for each student includes thestudent’s number, name, address, phone number and fees due. The college has twotypes of students, namely, on-campus students and distance students. The matricpoints obtained by on-campus students must also be stored. Additional information thatmust be stored for distance students includes the city of the study centre they will reportto and the duration over which they are completing the course. The fee for on-campusstudents is the sum of the course fee and a lab charge. In the case of distance studentsthe fee is a sum of the subject cost plus a postage cost for notes. Each student enrolsfor a course. The details that are stored for each course is the name of the course, thesubjects that need to be completed and the minimum duration of the course.

4. NRB bank manages a number of customer accounts. A customer can have one of threetypes 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 andbalance. Money can be withdrawn from an account or deposited into the account. Inthe case of both the savings and cheque accounts a withdrawal results in the balancebeing 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 accountsand 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 chequeaccount as accounts in these different categories have different benefits. Whenever adeposit is made into a savings account the customer earns interest on the updated

Page 2: Class Diagram

2

balance at a given rate. The interest rate used needs to be stored for each savingsaccount. Additional information needed for each loan account includes the duration ofthe loan in months, loan limit, and the monthly instalments.

5. A company requires a payroll system. The company has three types of employees,namely, a manager, a commission worker, and an hourly worker. Information that needsto be stored for each employee is the employee’s first name, surname, earnings andemployee number. Additional information that must be stored for a manager is his/hermonthly fixed salary; for a commission worker his/her flat salary, sales percent and thesales made for the month; for an hourly worker the number of hours worked and thewage per piece. Earnings must be calculated for each employee. A manager earns afixed monthly salary. A commission worker earns a flat monthly salary as well as apercentage of the sales he/she makes for the month. An hourly worker gets paidaccording to the number of hours worked. A fixed wage is set per hour. All employeesget a medical aid contribution. In addition to this managers get a pension as a fringebenefit. Each medical aid instance specifies the medical aid number, dependants,employee contribution and company contribution, while each pension instance specifiesthe pension number, beneficiaries, amount and date of retirement.