Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In python please Lab 1 2 B: My dog can do tricks For this lab we are going to create a Dog class. Dog objects

In python please
Lab12B: My dog can do tricks
For this lab we are going to create a Dog class.
Dog objects have a few attributes, but this time unlike chair objects they can also do some cool things too. Each action is represented by a method. Therefore, for any action our Dog can do or we do to the Dog, we are going to create a method. For example, if you want my Dog to bark, you can create a method to do that in the Dog class and call that method outside of the class (once you have created an object).
Dog class:
Variables (Attributes):
o age # current age of the dog, should be an int
o weight # weight in lbs, should be a float
o name # what is the name of the dog, a string
o furColor # color of the dogs fur/hair, a string
o breed # what breed is the dog, a string
Behaviors (Methods):
o bark # prints Woof! Woof!
o rename # take a string and change the name of the dog
o eat # take a float and add that number to weight
Keep in mind that methods inside of a class will always take the self parameter. This parameter is always automatically passed whenever you call a method from an object. However, some methods must take in more than just the self parameter; in this case, these extra parameters must be passed before the method can be called.
Outside the Dog class, create a new Dog object and prompt the user to input the attributes describing this Dog. Once done, print out all the details about the Dog, as per the sample output.
Next, use the methods you created in the Dog class to have it bark, change the name (using the rename method, not the dot operator), and feed it.
Finally print out all the details about the Dog, the object should have changed because of your calls to the various methods.
Sample output (user input in bold):
You are about to create a dog.
How old is the dog: 5
How much does the dog weigh: 30.5
What is the dogs name: Patches
What color is the dog: chocolate
What breed is the dog: lab
Patches is a 5 year old chocolate lab that weighs 30.5 lbs.
Woof! Woof!
Patches is hungry, how much should he eat: 5000.3
Patches isnt a very good name. What should they be renamed to: Sparky
Sparky is a 5 year old chocolate lab that weighs 5030.8 lbs.

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

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

Find dy/dx if x = te, y = 2t2 +1

Answered: 1 week ago