Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Back in the 90s, there was a popular toy called a Giga Pet, a digital pet that you could care for and raise. We

 

Back in the 90s, there was a popular toy called a Giga Pet, a digital pet that you could care for and raise. We can create our own version of a Giga Pet using Python classes. Create a class PyPet with at least the following methods (feel free to add your own): . _init_(self) Create a PyPet care(self) Take care of the egg until it hatches, user should give the egg words of encouragement feed(self) Feed your pet status(self) Check whether your pet is hungry Your PyPet class should also track several attributes of your pet, at a minimum: hatched whether your egg has hatched hatched_time the time when your egg hatched start the time your pet was created validation number of times you have cared for your pet last_fed the time your pet was last fed times_fed total times your pet has been fed level level of pet name name of pet Your egg should hatch after criteria based on both the times it has been cared for as well as total time you have had the egg. Your pet should level up after criteria based on time owned and times fed. Implement your PyPet class in a program that allows the user to raise their own PyPet. In []: from time import time In [] class Pypet: definit__(self): self.name=input('What is the name of your pet? ') self.created_time = time() self.hatched = False def status (self): self.total_time = time () - self.created_time if (not self.hatched) & (self.total_time > 30): print (Congratulations, your egg has hatched! '). self.hatched = True self.hatched_time = time () if not self.hatched: print('{.0f} seconds have elapsed since you got your egg'.format(self.total_time)) print('{:.0f} seconds have elapsed since your egg hatched'.format(time() - self.hatched_time)). else: In [] pet1 = PyPet()

Step by Step Solution

3.26 Rating (144 Votes )

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

Modern Systems Analysis And Design

Authors: Joseph Valacich, Joey George

8th Edition

0134204921, 978-0134204925

More Books

Students also viewed these Programming questions

Question

7:14 pm Sun 21 Mar Answered: 1 week ago

Answered: 1 week ago

Question

Explain the principles of object - oriented design patterns.

Answered: 1 week ago