Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN PYTHON 3. The two pictures below is the code I already have. the above pictures are instructions to add on to the code below.

IN PYTHON 3.

image text in transcribed

image text in transcribed

The two pictures below is the code I already have. the above pictures are instructions to add on to the code below.

image text in transcribed

image text in transcribed

>

class Pet: pet_owner = "X" def __init__(self, name, age): self.pet_name = name self.pet_age = age def __str__(self): output = "{0} is {1} year(s) old and is owned by {2}".format(self.pet_name, self.pet_age, Pet.pet_owner) return output

-------------------------------------------------------------------------------------------------------------------------------------------------

>

import pet pet_owner = input("Please enter owner's name:") print() pet.Pet.pet_owner = pet_owner pet_list = [] while True: pet_name = input("Please enter the pet's name") print() if pet_name == 'q' or pet_name == 'Q': break age = int(input("Please enter the pet's age")) print() pet_d = pet.Pet(pet_name, age) pet_list.append(pet_d) print("Pet List:") for pet in pet_list: print(pet)

4.7 Program: Pets! Again In this lab, you will be updating the Pets program. This uses your program from Chapter 3 as a base, so copy that work into this assignment as a starting point 1. (3 pts) Create a new class called Dog in pet py. This class should be a class derived from the Pet class. Create a class attribute in Dog for whether they are house broken (called "house") and initialize it to False (Boolean value). Your Dog constructor should take keyword parameters for dog_name and age dog age. The default value for name should be 'Spot' and for age be 1. 2. (2 pts) Override the print method in Dog to output a human-friendly version of the object/pet information Example Output Dog Sadie is 6 year(s) old, is owned by Fred, and is not house-broken 3. (1 pt) Add a method to Dog called set_house() to change the house broken value. It should take an argument of True or False 4.(3 pts) Create a new class called Beagle in pet py. This class should be a class derived from the Pet and Dog' class. Create a class attribute in Beagle for an integer value or ear floppiness (called "flop). Your Beagle constructor should take keyword parameters for bg_name and be age, behouse, and bg_flop. The defaults for these values should be 'Ace", 3, "yes", and 2 5. (2 pts) Override the print method in Beagle to output a human-friendly version of the object/pet information Example Output Beagle Sadie is 6 year(s) old, is owned by Fred, is house-broken, and has an ear floppiness of 7 6. (1 pt) Add a method to Dog called set_flop() to change the integer for ear floppiness. The only argument is an integer to for the new floppiness value 7. (3 pts) in main.py, modify the main function to test your new classes. The main function loop should prompt the user for an owner, name, age, and whether it is house broken first, it should then prompt for whether the Pet is a beagle or not. If it is ask for ear floppiness. Continue until the user enters a'd' or 'O' Finally, print out a list of all the current pets Example Output: Please enter the owner's name : Debbie Please enter the pet's name: Max Please enter the pet's age: 4 Is the dog house-broken? y Is the dog a beagle? n Please enter the owner's name: Louis Please enter the pet's name: Prince Please enter the pet's age: 2 Is the dog house-broken? n Is the dog a beagle? y How floppy are the ears? 7 Please enter the owner's name: Janice Please enter the pet's name: Newton Please enter the pet's age: 8 Is the dog house-broken? n Is the dog a beagle? n Please enter the owner's name: 0 Dog List: Dog Max is 4 year(s) old, is owned by Debbie, and is house-broken Beagle Prince is 2 year(s) old, is owned by Louis, is not house-broken, and has an ear floppiness of 7 Dog Newton is 8 year(s) old, is owned by Janice, and is not house-broken LAB ACTIVITY 4.7.1: Program: Pets! Again Current file: main.py Loa 2 ## Update your main code here 3 ## 5 import pet 6 pet owner - input("Please enter owner's name:") 7 print() 8 pet.Pet.pet owner - pet owner 9 pet_list = [] 10 while True: 11 pet_name - input("Please enter the pet's name") 12 print() if pet_name = 'q' or pet_name -- 'Q': break age - int(input("Please enter the pet's age")) print) pet_d - pet. Pet(pet_name, age) pet list.append(pet_d) 19 print("Pet List :") 20 for pet in pet_list: 21 print (pet) 22 13 16 18 Develop mode Submit mode When done developing your program press the Submit for grading button belc submit your program for auto-grading. Submit for grading CTIVITY 4.7.1: Program: Pets! Again Current file: pet.py 2 ## Create your classes here 3 # OU 5 class Pet: pet_owner - "X" WEB def __init__(self, name, age): self.pet_name = name self.pet_age - age def str_(self): output - "{@} is {1} year(s) return output and is owned by (2)".Format(self.pet_name, self.pet_age, Pet.pet_owner) 15 class Dog(Pet): def _init__(self, dog_name='Spot self.pet_name - dog_name 18 self.pet_age - dog_age dog_age-1): 20 Develop mode Submit mode When done developing your program press the Submit for grading button submit your program for auto-grading. Submit for grading

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 15th International Conference Dasfaa 2010 Tsukuba Japan April 2010 Proceedings Part 1 Lncs 5981

Authors: Hiroyuki Kitagawa ,Yoshiharu Ishikawa ,Wenjie Li ,Chiemi Watanabe

2010th Edition

3642120253, 978-3642120251

More Books

Students also viewed these Databases questions

Question

What is human nature?

Answered: 1 week ago