Question

This question is on PYTHON Object Oriented Programming using Lists only. I need the full python...


This question is on PYTHON Object Oriented Programming using Lists only. I need the full python coding for this question.

Write a FlightBooking class with 2 collections: flight(list) and landing(list). Follow names in the UML diagram given below.

UML DIAGRAM:
FlightBooking

_flight: list
_landing: list
__init__(self)
addFlight(self,flight)
addLanding(self,landing)
removeFlight(self,pilot,flightNo)
removeLanding(self,landingDateTime,destination)
searchFlight(self,pilot,flightNo) : Flight
searchLanding(self,landingDateTime,destination) : Landing
flightStr(self) : string
landingStr(self) : string

1. Constructor has 0 parameters, set collections to empty lists.

2. Add methods for both collections:

- 1 parameter each: adds an object to collection.

- Object can only be added if not a duplicate in the existing collection.

3. Remove methods for both collections:

- removeFlight has parameters: pilot and flightNo

- removeLanding has paramenters: landingDateTime and destination: Paris (True) or London (False)

- if object is found in collection, it is removed.

4. Search methods for both collections:

- searchFlight has parameters: pilot and flightNo

- searchLanding has paramenters: landingDateTime and destination: Paris (True) or London (False)

- if object is found, object with same values are returned, if not: None.

5. Book method:

- bookFlight has parameters: pilot, flightNo, landingDateTime and destination.

- method searches for flight in flight collection AND landing in landing collection.

- the passenger is then booked a flight by updating the instance in the flight from None to the flight details.

6. String methods for both collections.

7. Flight collection string output:

Pilot: John Flight No: EM123

Pilot: Francis Flight No: FM456

Pilot: George Flight No: GM789

Pilot: Henry Flight No: HM012

8. Landing collection string output:

Destination: Paris
Date and Time of Landing: 26 Oct 2015 10:20am
Booking Confirmed: No

Destination: London
Date and Time of Landing: 12 Feb 2016 07:30am
Booking Confirmed: No

9. Test class by:

- Adding objects in the 2 outputs given in Part 7 and Part 8 to FlightBooking.

- Remove flight with Pilot: Francis and Flight No: HM012 and again with Pilot: Francis but with Flight No: FM456 instead.

- Allocate Pilot: John and Flight No: EM123 to the passenger booking with the Destination: London (False) and Date and Time of Landing at 26 Oct 2015 10:20am and display

using a string.

information to add in each list is in part 7 and 8

0 0
Add a comment Improve this question Transcribed image text
Answer #1

class FlightBooking:
flight = []
landing = []
FlightBook = {}

def __init__(self):
self.flight.clear()
self.landing.clear()

def addFlight(self, flight):
if flight not in self.flight:
self.flight.append(flight)

def addLanding(self, landing):
if landing not in self.landing:
self.landing.append(landing)

def RemoveFlight(self, pilot, flightNo):
if str(pilot)+' '+str(flightNo) in self.flight:
self.flight.remove(pilot+' '+str(flightNo))

def RemoveLanding(self, landingDateTime, destination):
if str(landingDateTime)+' '+str(destination) in self.flight:
self.flight.remove(str(landingDateTime)+' '+str(destination))

def SearchFlight(self, pilot, flightNo):
if str(pilot)+' '+str(flightNo) in self.flight:
return str(pilot)+' '+str(flightNo)
else:
return None

def SearchLanding(self, landingDateTime, destination):
if str(landingDateTime)+' '+str(destination) in self.flight:
return str(landingDateTime)+' '+str(destination)
else:
return None

def BookFlight(self, pilot, flightNo, landingDateTime, destination):
if str(landingDateTime)+' '+str(destination) in self.flight:
if str(pilot)+' '+str(flightNo) in self.flight:
self.FlightBook[pilot] = flightNo

def FlightCollection(self):
for i in self.flight:
pilot, flightNo = i.split()
print('Pilot: {} Flight No: {}'.format(pilot, flightNo))

def LandingCollection(self):
for i in self.landing:
l, destination = i.split()
landingDateTime = ''
for i in l:
if i != '_':
landingDateTime += i
else:
landingDateTime += ' '
print('Destination: {}'.format(destination))
print('Date and Time of Landing: {}'.format(landingDateTime))
print('Booking Confirmed: No')


f1 = FlightBooking()
f1.addFlight('john EM123')
f1.addFlight('francis FM456')
f1.addLanding('Paris 26_Oct_2015_10:20am')
f1.addLanding('London 12_Feb_2016_07:30am')
f1.FlightCollection()
f1.LandingCollection()

e 1.py > FlightBooking 1 class FlightBooking: 2 flight I 3 4 FlightBook- landing - | 6 def_init_(sel) 7 8 self.flight.clearo

22 defRemoveLanding(self, landingDate Time, destination): 23 24 25 26 defSearchFlight(self pilot, flightNo): 27 28 29 30 if selse: 56 57 58 59 60 61 62 f1- FlightBooking0 63 f1.addFlight(john EM123) 64 f1.addFlight(francis FM456) 65 f1.addLanding(P

OUTPUT

PROBLEMS OUTPUT DEBUG CONSOLE TERMINAL Pilot: London Flight No: 12_Feb_2016_07:30am PS E:\fixer> cd e:\fixer; Şienv: PYTHONCOMMENT DOWN FOR ANY QUERY

PLEASE GIVE A THUMBS UP

Add a comment
Know the answer?
Add Answer to:
This question is on PYTHON Object Oriented Programming using Lists only. I need the full python...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The following is for java programming. the classes money date and array list are so I are are pre...

    The following is for java programming. the classes money date and array list are so I are are pre made to help with the coding so you can resuse them where applicable Question 3. (10 marks) Here are three incomplete Java classes that model students, staff, and faculty members at a university class Student [ private String lastName; private String firstName; private Address address; private String degreeProgram; private IDNumber studentNumber; // Constructors and methods omitted. class Staff private String lastName;...

  • Using Python. 3) Create a single-linked list (StudentList) where the data in the link is an object of type pointer to Student as defined below. Note that you need to store and pass a pointer of type...

    Using Python. 3) Create a single-linked list (StudentList) where the data in the link is an object of type pointer to Student as defined below. Note that you need to store and pass a pointer of type Student so that you do not create duplicate objects. Test your list with the provided program. You will find example code for a single-linked list of integers in Moodle that you can base your solution on. For your find methods, you can either...

  • Python Programming QUESTION 16 Which of the following is an example of a Keyword in Python?...

    Python Programming QUESTION 16 Which of the following is an example of a Keyword in Python? elif class for All of the above QUESTION 17 Which of the following is not an acceptable variable name in Python? 2ndVar $amount Rich& ard None of the above are acceptable variable names QUESTION 18 The number 1 rule in creating programs is ___________________- Write the code first Think before you program Let the compiler find you syntax errors There are no rules just...

  • PYTHON 3 Object Oriented Programming ***a9q3.py file below*** class GradeItem(object): # A Grade Item is anything...

    PYTHON 3 Object Oriented Programming ***a9q3.py file below*** class GradeItem(object): # A Grade Item is anything a course uses in a grading scheme, # like a test or an assignment. It has a score, which is assessed by # an instructor, and a maximum value, set by the instructor, and a weight, # which defines how much the item counts towards a final grade. def __init__(self, weight, scored=None, out_of=None): """ Purpose: Initialize the GradeItem object. Preconditions: :param weight: the weight...

  • Question from Object-Oriented Data Structures Using Java 4th Edition Chapter 5 Question 30 Add the following...

    Question from Object-Oriented Data Structures Using Java 4th Edition Chapter 5 Question 30 Add the following methods to the LinkedCollection class, and create a test driver for each to show that they work correctly. Code each of these methods by accessing the internal variables of the LinkedCollection, not by calling the previously defined methods of the class.String toString() creates and returns a string that correctly represents the current collection. 1. Such a method could prove useful for testing and debugging...

  • Objective In this assignment, you will practice solving a problem using object-oriented programming and specifically, you...

    Objective In this assignment, you will practice solving a problem using object-oriented programming and specifically, you will use the concept of object aggregation (i.e., has-a relationship between objects). You will implement a Java application, called MovieApplication that could be used in the movie industry. You are asked to implement three classes: Movie, Distributor, and MovieDriver. Each of these classes is described below. Problem Description The Movie class represents a movie and has the following attributes: name (of type String), directorName...

  • I need a python 3 help. Please help me with this question Part 2. Linked Lists...

    I need a python 3 help. Please help me with this question Part 2. Linked Lists You start working with the class LinkNode that represents a single node of a linked list. It has two instance attributes: value and next. class LinkNode: def __init__(self,value,nxt=None): assert isinstance(nxt, LinkNode) or nxt is None self.value = value self.next = nxt Before you start with the coding questions, answer the following questions about the constructor Valid Constructor or Not? LinkNode(1, 3) LinkNode(1, None) LinkNode(1,...

  • Hello, please solve this problem for object oriented programming in C++ program language. I have final...

    Hello, please solve this problem for object oriented programming in C++ program language. I have final tomorrow so it will be very helpful. thank you. PROBLEM 1: application that simulates the highway Create an In order to solve above mentioned requirements, it is necessary to implement several classes: 1. Class Vehicle contains information about the vehicles that drive on the highway. Each vehicle has information about its a Type (can be one of these: Motorcycle, Car, Truck) b. License number...

  • All those points need to be in the code Project 3 Iterative Linear Search, Recursive Binary...

    All those points need to be in the code Project 3 Iterative Linear Search, Recursive Binary Search, and Recursive Selection Sort Class River describes river's name and its length in miles. It provides accessor methods (getters) for both variables, toString() method that returns String representation of the river, and method isLong() that returns true if river is above 30 miles long and returns false otherwise. Class CTRivers describes collection of CT rivers. It has no data, and it provides the...

  • I'm using Python 3.7 with Spyder I need the full code and the same output as...

    I'm using Python 3.7 with Spyder I need the full code and the same output as the sample above Resources file: https://drive.google.com/file/d/1e5a21ZKRj2H_jOnWvg7HcjUKjJlY84KE/view -   https://drive.google.com/file/d/1XIA41ra8AaKjFuxO5VpwVkn90bxwDyB5/view Task description Baye's Theorem can be used to build many machine learning applications, including spam classifier Spam Classifier in Python from scratch is a tutorial which explains how to use Bave's Theorem and Python to develop a spam classifier step by step To train the spam classifier, one dataset "spam.csv" is used in the program Its...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT