Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

COuld you please help me solve this python3 questions? The answers build off of each other each time, so I'd really appreciate your help answering

COuld you please help me solve this python3 questions? The answers build off of each other each time, so I'd really appreciate your help answering them all. Thanks!

Task 01

Create a class of your choosing. It can be an animal class or a bank account class. Choose something that you are passionate about and familiar with and create it. For the purposes of illustration, I will be using a dog class as an example. While I would prefer you to create your own unique class, you may use a dog class so long as you do not copy my code and you are super passionate about dogs. Your class should have the following:

- Three protected class variables to store key information about the class

- An __init__ constructor that populates the aforementioned class variables

Example structure

class Dog:

size = smol

rate = 10

name = Schmoopy

__init__(size, rate, name):

size = size

rate = 10

name = name

Task 02

Now its time to add some interactivity to your previous script. Take the class you created in the add the following:

- One method that will accept an input, update one of the class variables, and return the new value

- One method that will accept an input, perform some kind of error checking, update one of the class variables, and return the new value

Example structure

set_size(newsize):

size = newsize

return size

increment_cute(number):

if rate < 10:

rate += number

return rate

else

return false

Task 03

Now were going to add even more interactivity to your class. Building on what you have so far, you will now add the following:

- overload the str() and len() methods to return useful information for your class

- overload the equivalence operator (==) such that its use with your class will compare one of the variables and return true if they are the same and false otherwise

Example structure

__str__():

return name

__len__():

return size

__==__(otherdog):

if rate == otherdog.rate

return True

else

return False

Task 04

Now its time to get some use out of your class. You will create the following:

- Define a new class that inherits from your previous class

- Override one of your methods to provide new functionality

- Define a new method specific to this class

Example structure

class RescueDog(Dog)

increment_cute(number):

if rate < 20:

rate += number

return rate

else

return false

puppy_dog_eyes():

rate += 1

return rate

Task 05

Now were going to add some more complexity to our class. You are to add the following:

- Create a new class that inherits from your original class

- Add two new private class variables

- Override the constructor to only accept these new variables

- Override one of your methods to accept a numeric value and use that in a condition

- Add a class variable that is a number

- Add a new method that will take in a number and add it to with the previously created numeric value so long as it is within a certain range

Example structure

class Pug

squishface = true

grossrating = 10

__init__(size, rate, name, squishface, grossrating):

increment_cute(number, grossrating):

if grossrating > 8:

return false

else:

rate += number

return rate

wrinkles = 25

wrinkle(newwrinkles):

if wrinkles + newwrinkles < 50:

wrinkles += newwrinkles

else:

print("That's too many wrinkles, man")

return false

Thanks a lot!

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_2

Step: 3

blur-text-image_step3

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

More Books

Students also viewed these Databases questions

Question

What is a verb?

Answered: 1 week ago

Question

=+5 How does HRM relate to efforts to increase innovation?

Answered: 1 week ago