Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Parks Canada Program with inherited national and provincial parks subclasses.
- # Park class which is the superClass of the program.
- class Park:
- noOfParks = 0
- counter = 0
- def __init__(self, name, location, area, established):
- Park.counter = Park.counter + 1
- self._Name = name
- self._Location = location
- self._Area = area
- self._Established = established
- def setArea(self, area):
- self._Area = area
- print("Park Name:", self._Name)
- print("Updated Park Area:", self._Area)
- def getName(self):
- return self._Name
- def getLocation(self):
- return self._Location
- def getArea(self):
- return self._Area
- def getEstablished(self):
- return self._Established
- def getEntryFee(self, noOfDays):
- fee = 5 * noOfDays
- print("The cost for",noOfDays,"days in General park is $ %.2f" %fee)
- def __str__(self):
- return "Park Name: " + str(self._Name) + "\nLocation: " + self._Location + "\nArea Covered (km^2): " + str(self._Area) + "\nYear Established: " + str(self._Established)
- # The Provincial Park subclass which inherits the data from the Park class.
- class ProvincialPark(Park):
- def __init__(self,name, location, area, established, parkRating):
- super().__init__(name, location, area, established)
- self._ParkRating = parkRating
- def setParkRating(self, parkRating):
- self._ParkRating = parkRating
- print("Park Name:", super().getName())
- print("Updated Rating:", self._ParkRating)
- def getParkRating(self):
- return self._ParkRating
- def getEntryFee(self, noOfDays):
- if self._ParkRating == 1:
- fee = (30+5) * noOfDays
- elif self._ParkRating == 2:
- fee = (25+5) * noOfDays
- elif self._ParkRating == 3:
- fee = (20+5) * noOfDays
- print("The Cost for", noOfDays, "days in", super().getName() , "Park is $ %.2f"%fee)
- def Park__str__(self):
- return "Name of Park: " + str(super().getName()) + "\nLocation of Park: " + self._Location + "\nArea of Park: " + str(super().getArea()) + "\nYear Established: " + str(super().getEstablished()) + "\nPark Rating: " + str(self._ParkRating)
- # The national parks class which is a subclass of the Parks class and inherits the data.
- class NationalPark(Park):
- def __init__(self, name, location, area, established, knownFor):
- super().__init__(name, location, area, established)
- self._knownFor = knownFor
- def setknownFor(self, knownFor):
- self._knownFor = knownFor
- print("Park Name:",self._Name)
- print("Updated Feature:",knownFor)
- def getknownFor(self):
- return self._knownFor
- def getEntryFee(self, noOfDays):
- fee = ((5*noOfDays) + ((super().getArea() * 0.03)*noOfDays))
- print("The cost for",noOfDays,"days in",self._Name ,"is $%.2f" %fee)
- def Park__str__(self):
- return "Name of Park: " + str(super().getName()) + "\nLocation of Park: " + self._Location + "\nArea of Park: " + str(super().getArea()) + \
- "\nYear Established: " + str(super().getEstablished()) + "\nKnown For: " + self._knownFor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement