Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Country: # creates the Country class
- def __init__(self, name, pop, area, continent): # constructor that initializes name, pop, area, continent
- self._pop = pop
- self._area = area
- self._continent = continent
- self._name = name
- def __repr__(self): # constructor that returns class methods as a string
- return "%s (pop: %s, size: %s) in %s" % (str(self._name), str(self._pop), str(self._area), str(self._continent))
- # population of a country
- def setPopulation(self, pop): # set the population
- self._pop = self._pop + pop
- def getPopulation(self): # call the population
- return self._pop
- # area of a country
- def setArea(self, area): # set the area
- self._area = self._area + area
- def getArea(self): # call the area
- return self._area
- # continent of a country
- def setContinent(self, continent): # set the continent
- self._continent = self._continent + continent
- def getContinent(self): # call the continent
- return self._continent
- # name of a country
- def setName(self, name): # set the name
- self._name = self._name + name
- def getName(self): # call the name
- return self._name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement