0% found this document useful (0 votes)
6 views7 pages

Object-Oriented Flight Management Project

The document outlines a project focused on object-oriented programming, specifically creating a Flight class with various functionalities related to seat sales and flight management. It includes two main problems: the first involves implementing seat sales and tracking sales data, while the second extends the functionality to allow for cancellable seat purchases with refund capabilities. Instructions for creating a Jupyter Notebook and submitting the project are also provided.

Uploaded by

Jem Pimentel
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views7 pages

Object-Oriented Flight Management Project

The document outlines a project focused on object-oriented programming, specifically creating a Flight class with various functionalities related to seat sales and flight management. It includes two main problems: the first involves implementing seat sales and tracking sales data, while the second extends the functionality to allow for cancellable seat purchases with refund capabilities. Instructions for creating a Jupyter Notebook and submitting the project are also provided.

Uploaded by

Jem Pimentel
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

🛡

Project 3: Object-oriented
programs
Date Nov 12, 2020

Module Module 4 Object-oriented programming

Type Project

General Instructions
Problem A Flights 50 pts)
Problem B Flights, extended 50 pts)

General Instructions
 This exercise consists of multiple short problems. Create one Jupyter
Notebook file for the entire exercise.

 The first cell of the file should contain header information:

 Your full name and ID number

 Date you created your program

 Save each solution to a problem in a single code cell. Each code cell
should have the name of the problem commented at the very top of the
cell.

 Save your Jupyter notebook as project04-surname-idnumber . Zip the folder


containing your Jupyter notebook submission using the same name.
Ensure that you include a properly accomplished Certificate of Authorship
Individual), citing all external sources used, in the zipped folder.

 The zipped folder should be submitted through the appropriate Moodle


submission module. Make sure to double check to see that you've
successfully uploaded the correct zipped folder.

Project 3 Object-oriented programs 1


Problem A: Flights (50 pts)
A flight has three seat prices: regular, discount, and premium. The discount
seat is 10% cheaper than the regular seat. The premium seat is 10% more
expensive than the regular seat. A customer can buy any combination of
regular, discount, and premium seats. However, the total number of seats that
a customer requests cannot exceed the seats available. Every time the plane
flies, it incurs a cost for fuel.

Create a class called Flight with the following characteristics:

 The price of a regular seat is initially set for 2000.

 The flight has 300 seats available per ride.

 The flight tracks total sales.

 The flight must also count the number of regular, discount, and
premium seats sold.

 The flight must track the cost of fuel.

 The cost of fuel per flight is 30,000.

The Flight must implement the following methods:

 __init__(self) :

 The constructor initializes the values of all the fields

 sellSeats(self, regSeats, discountSeats, premiumSeats) :

 If there aren't enough seats, the method ends and prints "Total cost is
0.0".

 If there are enough seats available, the method computes the cost,
decreases the number of seats available and updates the counts of the
different seat types.

 The method updates the total sales.

 The method prints the total cost of the transaction.

 flyPlane(self) :

 The method increases the total fuel cost.

 The method resets the number of seats available to 300.

 changeSeatPrice(self, newCost) :

Project 3 Object-oriented programs 2


 The method updates the price per seat to the value indicated in the
parameter.

 changeFlightCost(self, newCost) :

 The method updates the cost per flight to the value indicated in the
parameter.

 printReport(self)

 The method prints the total sales, the number of regular, discount and
premium seats sold and the total cost of all the flights.

On a separate code cell, do the following instructions in the same sequence:

 Create a Flight named pal .

 A customer attempts to buy 30 regular seats, 25 discount seats and 40


premium seats. Print the total bill followed by the report.

 The plane flies.

 A customer attempts to buy 50 regular seats, 100 discount seats and 100
premium seats. Print the total bill followed by the report.

 A customer attempts to buy 60 regular seats, 70 discount seats and 15


premium seats. Print the total bill.

 The plane flies.

 Print the report.

 The regular seat price changes to 3000.00.

 A customer attempts to buy 45 regular seats, 70 discount seats and 20


premium seats. Print the total bill followed by the report.

 A customer attempts to buy 150 regular seats, 0 discount seats and 10
premium seats. Print the total bill.

 The plane flies.

 The fuel cost changes to 50,000 per run.

 A customer attempts to buy 180 regular seats, 65 discount seats and 0
premium seats. Print the total bill followed by the report.

Project 3 Object-oriented programs 3


 A customer attempts to buy 50 regular seats, 240 discount seats and 20
premium seats.

 The plane flies.

 Print the report.

# Put the Flight class here


...
# Put the Flight class here

# Put the test commands here


...
# Put the test commands here

[OUT]:
Total cost is 193000.0
----Sales Report-----
Total sales 193000.0
Total regular seats sold 30
Total discount seats sold 25
Total premium seats sold 40
Total flight cost 0.0
---------------------
Total cost is 500000.0
----Sales Report-----
Total sales 693000.0
Total regular seats sold 80
Total discount seats sold 125
Total premium seats sold 140
Total flight cost 30000.0
---------------------
Total cost is 0.0
----Sales Report-----
Total sales 693000.0
Total regular seats sold 80
Total discount seats sold 125
Total premium seats sold 140
Total flight cost 60000.0
---------------------
Total cost is 390000.0
----Sales Report-----
Total sales 1083000.0
Total regular seats sold 125
Total discount seats sold 195
Total premium seats sold 160
Total flight cost 60000.0
---------------------
Total cost is 483000.0
Total cost is 715500.0
----Sales Report-----
Total sales 2281500.0
Total regular seats sold 455
Total discount seats sold 260
Total premium seats sold 170

Project 3 Object-oriented programs 4


Total flight cost 90000.0
---------------------
Total cost is 0.0
----Sales Report-----
Total sales 2281500.0
Total regular seats sold 455
Total discount seats sold 260
Total premium seats sold 170
Total flight cost 140000.0
---------------------

Problem B: Flights, extended (50 pts)


Create a CancellableSeatsFlight class that inherits from Flight . This class
tracks the most recent regular, discount, and premium seats that were bought.
The latest purchase can be cancelled, and cost for the tickets can be refunded
by a refund rate. The refund rate starts at 50%
The CancellableSeatsFlight must implement/override the following methods:

 __init__(self) :

 The constructor initializes the values of the new fields that track the
most recent seats bought and the refund rate.

 sellSeats(self, regSeats, discountSeats, premiumSeats):

 If there aren't enough seats, the method ends and prints "Total cost is
0.0".

 If there are enough seats available, the method tracks the latest
number of seats bought

 The method calls the superclass' sellSeats() method

 cancelSeats(self) :

 The latest seats are deducted from the running totals of bought seats

 The cost of the latest seats bought is deducted from the total sales at
the refund rate (e.g. if the refund rate is 50%, a cancelled 10000-worth
of seats is refunded only 5000.

 The method prints the total sales that are refunded.

 changeRefundRate(self, newRate) :

Project 3 Object-oriented programs 5


 The method updates the refund rate to the value indicated in the
parameter.

On a separate code cell, do the following instructions in the same sequence:

 Create a CancellableSeatsFlight named ceb .

 A customer attempts to buy 30 regular seats, 80 discount seats and 80


premium seats. Print the total bill followed by the report.

 A customer attempts to buy 60 regular seats, 70 discount seats and 15


premium seats. Print the total bill followed by the report.

 A customer attempts to buy 20 regular seats, 30 discount seats and 40


premium seats. Print the total bill followed by the report.

 Cancel the latest seats bought.

 The plane flies.

 Print the report.

 The refund rate changes to 40%.

 A customer attempts to buy 50 regular seats, 50 discount seats and 50


premium seats. Print the total bill followed by the report.

 A customer attempts to buy 40 regular seats, 30 discount seats and 20


premium seats. Print the total bill followed by the report.

 Cancel the latest seats bought.

 The plane flies.

 Print the report.

# Put the CancellableSeatsFlight class here


...
# Put the CancellableSeatsFlight class here

# Put the test commands here


...
# Put the test commands here

[OUT]:
Total cost is 380000.0
----Sales Report-----
Total sales 380000.0
Total regular seats sold 30
Total discount seats sold 80
Total premium seats sold 80
Total flight cost 0.0

Project 3 Object-oriented programs 6


---------------------
Total cost is 0.0
----Sales Report-----
Total sales 380000.0
Total regular seats sold 30
Total discount seats sold 80
Total premium seats sold 80
Total flight cost 0.0
---------------------
Total cost is 182000.0
----Sales Report-----
Total sales 562000.0
Total regular seats sold 50
Total discount seats sold 110
Total premium seats sold 120
Total flight cost 0.0
---------------------
Total refunded sales is 91000.0
----Sales Report-----
Total sales 471000.0
Total regular seats sold 30
Total discount seats sold 80
Total premium seats sold 80
Total flight cost 30000.0
---------------------
Total cost is 300000.0
----Sales Report-----
Total sales 771000.0
Total regular seats sold 80
Total discount seats sold 130
Total premium seats sold 130
Total flight cost 30000.0
---------------------
Total cost is 178000.0
----Sales Report-----
Total sales 949000.0
Total regular seats sold 120
Total discount seats sold 160
Total premium seats sold 150
Total flight cost 30000.0
---------------------
Total refunded sales is 71200.0
----Sales Report-----
Total sales 877800.0
Total regular seats sold 80
Total discount seats sold 130
Total premium seats sold 130
Total flight cost 60000.0
---------------------

Project 3 Object-oriented programs 7

You might also like