Hey there I am struggle with importing a existing class in PYTHON in the order below for class PLANE (Landingspot CLASS with objects ID, city, country )and am trying to import to another class module PLANE(flightNumber, Start, goingTo). Each class would be eventually reading from text files with some spaces and commas separating randomly. '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 First class I have finished Class Landingsport (self, ID, country, city) self.ID= ID self.country = country self.city = city REPR Getters and setter done ****but when I get to the other class I find issues
Hey there I am struggle with importing a existing class in PYTHON in the order below for class PLANE
(Landingspot CLASS with objects ID, city, country )and am trying to import to another class module PLANE(flightNumber, Start, goingTo). Each class would be eventually reading from text files with some spaces and commas separating randomly.
'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
First class I have finished
Class Landingsport (self, ID, country, city)
self.ID= ID
self.country = country
self.city = city
REPR
Getters and setter done
****but when I get to the other class I find issues
Second class
From landingSpot import *
class Plane
*import from Landingspot as it makes use of Landingspot objects; add the line from Landingspot import *
__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):
o 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, origin):
Setter that sets (updates) the Plane Start
setgoingTo(self, destination):
Setter that sets (updates) the Plane GoingTo
Step by step
Solved in 3 steps