Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
1,332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. '''
  2. Animal Welfare Trust is on a visit to the circus camp to have a look at the four talking parrots added to the camp.
  3. A parrot is identified by its name and color. Apart from this, the trust has asked to assign a unique number for each parrot. The unique number should begin with 7001 and should be auto-incremented by 1 for every new parrot added to the camp.
  4.  
  5. Write a Python program to implement the class chosen with its attributes and methods. Represent few parrots, display their names, color and unique number.
  6.  
  7.  
  8. Note: Consider all the attributes to be private and methods to be public. Include getter methods for all the instance variables.
  9.  
  10.  
  11. '''
  12.  
  13. #OOPR-Assgn-15
  14. #Start writing your code here
  15. class Parrot:
  16. __counter=7000
  17. def __init__(self,name,color):
  18. Parrot.__counter+=1
  19. self.__name=name
  20. self.__color=color
  21. self.__unique_number=Parrot.__counter
  22.  
  23. def get_name(self):
  24. return self.__name
  25.  
  26. def get_color(self):
  27. return self.__color
  28.  
  29. def get_unique_number(self):
  30. return self.__unique_number
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement