'Within the PLANE class, you must implement the following functions based on these descriptions and specifications:" *import from Landingspot as it makes use of Landingspot objects; add the line from Landingspot import * From landingSpot import * class Plane __init__(self, flightNumber, Start, goingTo): First check that both Start and goingTo are Airport objects : use the isinstance operator). If either or both are not Plane objects, raise a TypeError that states "The Start and goingTo must be plane objects" When the Start and goingTo are both Plane objects, proceed to initialize the instance variables _flightNumber, _start, and _goingTo based on the corresponding parameters in the constructor __repr__(self): Return the representation of this Plane - containing the flightNo, origin city, and destination city, and an indication of whether the Flight is international or domestic (see the isDomesticFlight method description below). The representation must be in the following format: Plane: flightNumber from startCity to goingToCity {domestic/international} EX Flight: MLK523 from London to Manchester {domestic} EX Flight: WBQ345 from London to Chicago {international} __eq__(self, other): Method that returns True if self and other are considered the same Flight: if the origin and destination are the same for both Flights. Make sure that if “other” variable is not a Flight object, this means False should be returned. getFlightNumber(self): Getter that returns the Flight number getStart(self): Getter that returns the Plane Start getgoingTo(self): Getter that returns the Plane destination isDomesticFlight(self): Method that returns True if the flight is domestic, EX within a country (the Start and goingTo are in the same country); returns False if the flight is international (the Start and goingTo are in different countries) setStart(self, start): Setter that sets (updates) the Plane Start setgoingTo(self, goingTo): Setter that sets (updates) the Plane GoingTo
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Hey there I am struggling with creating a second class module in PYTHON - that would import an already existing class I have finished from another module file called LANDINGSPOT,
the class I am struggling with follows the exact order below* - class PLANE
- first-class which is done (Landingspot CLASS with objects ID, city, country )
- and am trying to create another class module PLANE. (flightNumber, Start, goingTo).
Each class would be eventually reading from text files with some spaces and commas separating randomly that’s where they would be getting data but that's for another module, which would need to import PLANE class.
- 'As suggested by its name, this class represents a 'Plane' from one landingSpot to another landingSpot in the program.
- Each Plane object must have a flightNumber (the unique 6-character code containing 3 letters followed by 3 digits), Start place, and a goingTo. Both the Start and goingTo must be LandingSpot objects within the program.'
Landingspot
Ex textfile contains
JFK,UnitedStates, NewYork
PHL,UnitedStates,Philadelphia
etc
Class Plane EX text file contains
KPP582,YYZ,ICN
VDT680,JRS,PHL
XPA230,YEG,ORD
XGY802, YUL,GIG
JHW048,ORD,NBO
KGM892,SYD,JRS
XUC141,JFK, DEN
RIN900,FCO,PEK
EKR896,SFO, YHZ
etc
First class I have finished
Class Landingsport (self, ID, country, city)
self.ID= ID
self.country = country
self.city = city
REPR. done***
Getters and setter done***
****but when I get to the other class I find issues****
Second class where I need help****
'Within the PLANE class, you must implement the following functions based on these descriptions and specifications:"
*import from Landingspot as it makes use of Landingspot objects; add the line from Landingspot import *
From landingSpot import *
class Plane
__init__(self, flightNumber, Start, goingTo):
- First check that both Start and goingTo are Airport objects : use the isinstance operator).
If either or both are not Plane objects, raise a TypeError that states "The Start and goingTo must be plane objects"
- When the Start and goingTo are both Plane objects, proceed to initialize the instance variables _flightNumber, _start, and _goingTo based on the corresponding parameters in the constructor
__repr__(self):
- Return the representation of this Plane - containing the flightNo, origin city, and destination city, and an indication of whether the Flight is international or domestic (see the isDomesticFlight method description below). The representation must be in the following format: Plane: flightNumber from startCity to goingToCity {domestic/international}
EX Flight: MLK523 from London to Manchester {domestic}
EX Flight: WBQ345 from London to Chicago {international}
__eq__(self, other):
- Method that returns True if self and other are considered the same Flight: if the origin and destination are the same for both Flights. Make sure that if “other” variable is not a Flight object, this means False should be returned.
getFlightNumber(self):
- Getter that returns the Flight number
getStart(self):
- Getter that returns the Plane Start
getgoingTo(self):
- Getter that returns the Plane destination
isDomesticFlight(self):
- Method that returns True if the flight is domestic, EX within a country (the Start and goingTo are in the same country); returns False if the flight is international (the Start and goingTo are in different countries)
setStart(self, start):
- Setter that sets (updates) the Plane Start
setgoingTo(self, goingTo):
- Setter that sets (updates) the Plane GoingTo
Step by step
Solved in 3 steps with 1 images