Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. # Parks Canada Program with inherited national and provincial parks subclasses.
  2.  
  3. # Park class which is the superClass of the program.
  4.  
  5.  
  6. class Park:
  7.  
  8. noOfParks = 0
  9. counter = 0
  10.  
  11. def __init__(self, name, location, area, established):
  12. Park.counter = Park.counter + 1
  13. self._Name = name
  14. self._Location = location
  15. self._Area = area
  16. self._Established = established
  17.  
  18. def setArea(self, area):
  19. self._Area = area
  20. print("Park Name:", self._Name)
  21. print("Updated Park Area:", self._Area)
  22.  
  23. def getName(self):
  24. return self._Name
  25.  
  26. def getLocation(self):
  27. return self._Location
  28.  
  29. def getArea(self):
  30. return self._Area
  31.  
  32. def getEstablished(self):
  33. return self._Established
  34.  
  35. def getEntryFee(self, noOfDays):
  36. fee = 5 * noOfDays
  37. print("The cost for",noOfDays,"days in General park is $ %.2f" %fee)
  38.  
  39. def __str__(self):
  40. return "Park Name: " + str(self._Name) + "\nLocation: " + self._Location + "\nArea Covered (km^2): " + str(self._Area) + "\nYear Established: " + str(self._Established)
  41.  
  42.  
  43. # The Provincial Park subclass which inherits the data from the Park class.
  44. class ProvincialPark(Park):
  45.  
  46. def __init__(self,name, location, area, established, parkRating):
  47. super().__init__(name, location, area, established)
  48. self._ParkRating = parkRating
  49.  
  50. def setParkRating(self, parkRating):
  51. self._ParkRating = parkRating
  52. print("Park Name:", super().getName())
  53. print("Updated Rating:", self._ParkRating)
  54.  
  55. def getParkRating(self):
  56. return self._ParkRating
  57.  
  58. def getEntryFee(self, noOfDays):
  59.  
  60. if self._ParkRating == 1:
  61. fee = (30+5) * noOfDays
  62. elif self._ParkRating == 2:
  63. fee = (25+5) * noOfDays
  64. elif self._ParkRating == 3:
  65. fee = (20+5) * noOfDays
  66. print("The Cost for", noOfDays, "days in", super().getName() , "Park is $ %.2f"%fee)
  67.  
  68. def Park__str__(self):
  69. 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)
  70.  
  71.  
  72. # The national parks class which is a subclass of the Parks class and inherits the data.
  73. class NationalPark(Park):
  74.  
  75. def __init__(self, name, location, area, established, knownFor):
  76. super().__init__(name, location, area, established)
  77. self._knownFor = knownFor
  78.  
  79. def setknownFor(self, knownFor):
  80. self._knownFor = knownFor
  81. print("Park Name:",self._Name)
  82. print("Updated Feature:",knownFor)
  83.  
  84. def getknownFor(self):
  85. return self._knownFor
  86.  
  87. def getEntryFee(self, noOfDays):
  88. fee = ((5*noOfDays) + ((super().getArea() * 0.03)*noOfDays))
  89. print("The cost for",noOfDays,"days in",self._Name ,"is $%.2f" %fee)
  90.  
  91. def Park__str__(self):
  92. return "Name of Park: " + str(super().getName()) + "\nLocation of Park: " + self._Location + "\nArea of Park: " + str(super().getArea()) + \
  93. "\nYear Established: " + str(super().getEstablished()) + "\nKnown For: " + self._knownFor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement