Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Here are your instructions:
- This project tests more of your understanding of classes and objects.
- Create a new Pydev project named Lesson14_Homework.
- Add the project to your Python1_Homework working set.
- Create a new Python source file in your Lesson14_Homework/src folder named doggies.py.
- Write a class named Dog. Dog's __init__() method should take two parameters, name and breed, in addition to the implicit self.
- Bind an empty list to a dogs variable.
- Using a while loop, get user input for name and breed. The loop should terminate when the user enters a blank name.
- For each name and breed entered, create an instance of the Dog class with name and breed as arguments. Append the object to the dogs list.
- Each time around the loop, print the current dogs list (the name and breed of each dog).
- Below is an example of possible output from running the program.
- Name: Snoopy
- Breed: Beagle
- DOGS
- 0. Snoopy:Beagle
- ****************************************
- Name: Marmaduke
- Breed: Great Dane
- DOGS
- 0. Snoopy:Beagle
- 1. Marmaduke:Great Dane
- ****************************************
- Name: Rover
- Breed: Mutt
- DOGS
- 0. Snoopy:Beagle
- 1. Marmaduke:Great Dane
- 2. Rover:Mutt
- ****************************************
- Name:
Add Comment
Please, Sign In to add comment