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
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 struggle with importing a existing class in PYTHON
(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.
'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
SVF907,MAA,IBN
MWD542, TIP,YNR
etc
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
*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 5 steps with 3 images