Inheritance Base class: Create an inheritance hierarchy to represent various types of memberships. Use KrisFlyer as the
Question:
Inheritance
Base class: Create an inheritance hierarchy to represent various types of memberships. Use
KrisFlyer as the base class of the hierarchy, then include derived classes Basic, Elite Silver and
Elite Gold that deriver from KrisFlyer. Base class KrisFlyer should have data members
representing name, membership, flight, price for flight, number of passengers for the members.
The constructor should initialize these data members. Ensure that flight price and number of
passengers contain positive values. KrisFlyer should include a public member function
calculateCost() that returns a double indicating the cost by multiplying the price for flight by the
number of passengers.
Derived class: Basic, Elite Silver and Elite Gold should inherit the functionality of base
class KrisFlyer, but also include a data member that represents a discount that the reward program
has offered recently. All the derived class’s constructor should receive a value to initialize this data
member. In 2020, Singapore Airlines offers a flat 10%, 20% and 30% discount to its Basic, Elite
Silver and Elite Gold members respectively for all services provided. All the derived members
should redefine calculateCost() so that it applies the discount to the booked flights. It shall compute
the total bill if a customer purchases y tickets for a price of $x for each flight for their visit using
Krisflyer.
Your system shall consist of four classes: 1. KrisFlyer (base class), derived classes
including Basic, Elite Silver, Elite Gold.
Polymorphism
Implement a method display() that displays all the records of the system. Another form of
the method display(string cust_name) that displays records related to the customer name passed in
the argument.
Encapsulation
Define the instance variables private/ public so that they cannot/can be accessed from
outside the class. Implement getter and setter method for the variables in the program.
Write a program that implements basic Object-oriented concepts including encapsulation
polymorphism and inheritance. Also, the program is expected to get the basic input from the user
based on either console/Desktop.
The student is expected to do the following tasks:
1. Draw the class diagram of the given scenario
1. Write the c# classes with suggested data members and functions
2. Write the base and derived classes for implementing inheritance in the program.
3. Implement polymorphism and encapsulation to check for accessibility of data members
and different form of the data member
4. Write the main logic that takes input from the user members with their bookings
4 Write the code to display the output as displayed (it is a sample)
Expected output
ITAP1001 Assignment
The given output is a sample. The student is free to use creative ideas to display the output of the
program. It needs to be an interactive session where the user feeds in dynamic information.
KrisFlyers Reward Discount system
Basic 10%
Elite silver 20%
Elite gold 30%
Hello, Input based on your requirement
1. To input new entry
2. Display a single record:
3. Display all records
4. Exit
1
Enter the name of the customer : XYZ
Enter the membership type : Basic
Enter the price for flight in dollars ($): 1200
Enter the number of passengers : 2
Hello, Input based on your requirement
1. To input new entry
2. Display a single record:
3. Display all records
4. Exit
2
Enter the name of the customer
XYZ
| Name | Price | No | Total | discount | Discounted Price |
| XYZ | $1200 | 2 | $2400 | 10% | $2160 |
Hello, Input based on your requirement
1. To input new entry
2. Display a single record:
3. Display all records
4. Exit
3
| Name | Price | No | Total | discount | Discounted Price |
| XYZ | $1200 | 2 | $2400 | 10% | $2160 |
| ABC | $1000 | 1 | $2000 | 10% | $1800 |
ITAP1001 Assignment
Data Structures and Algorithms in Python
ISBN: 978-1118290279
1st edition
Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser