forked from codepath/compsci_guides
-
Notifications
You must be signed in to change notification settings - Fork 0
Pokemon Class
Jessica Sang edited this page Sep 14, 2024
·
1 revision
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.
- How do we use the provided class to create an instance?
- By using the constructor method
__init__
that has been predefined in the class to initialize a new object with specific attributes.
- By using the constructor method
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Instantiate a Pokemon object with the specified name and types by calling the constructor.
1) Instantiate a Pokemon object using the class constructor, providing "Pikachu" for the name and ["Electric"] for the types.
2) Store the new object in a variable named `my_pokemon`.
- Not using the correct syntax for object instantiation.
- Misspelling variable names or class names.
my_pokemon = Pokemon("Pikachu", ["Electric"])