- 
                Notifications
    You must be signed in to change notification settings 
- Fork 266
Catch Pokemon
        Sar Champagne Bielert edited this page Apr 19, 2024 
        ·
        5 revisions
      
    Unit 5 Session 1 (Click for link to problem statements)
Understand what the interviewer is asking for by using test cases and questions about the problem.
- Do we need to modify any of the existing class methods?
- No. You only need to add the new method.
 
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Extend the Pokemon class by adding a new method catch() which sets the is_caught attribute to True.
1) Define a method `catch` within the Pokemon class that changes `is_caught` to True.
2) This method does not take parameters other than `self` and does not return any value.- Not including the selfparameter in the method definition.
- Attempting to return a value from a method that should only update an attribute.
class Pokemon:
    def __init__(self, name, types):
        self.name = name
        self.types = types
        self.is_caught = False
    def print_pokemon(self):
        print {'name': self.name, 'types': self.types,
               'is_caught': self.is_caught}
    # New code:
    def catch(self):
        self.is_caught = True