write a Cat class so that you can make a cat object and interact with it....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
write a Cat class so that you can make a cat object and interact with it. Make a class Cat. This class should have the following: • A name attribute that is intialized when a cat is created. • An energy attribute that has an initial value of 2. • A stomach capacity attribute that has an initial value of 2. • A method called play(). If the value of energy is greater than 0, it prints a message similar to "catname says meow" and then reduces the value of energy by 1. The message has to contain the name of the cat and the sound meow. However, if the value of energy is less than or equal to 0, it prints "catname is tired" instead. • A method called eat(). If the capacity of stomach is greater than 0, it prints a message similar to "catname says nom" and then reduces the capacity of stomach by 1. The message has to contain the name of the cat and the sound nom. However, if the capacity of stomach is less than or equal to 0, it prints "catname is full" instead. In main(), you should have the following: • The program asks the user to enter a name and then creates a cat object with that name. • The program then asks how the user would like to interact with the cat by entering either 'play' or 'feed' . Once the user enters the option, the program calls the corresponding methods from the Cat class to perform the interaction. Once the interaction is completed, the program should ask if the user would like to continue. If the user enters 'y, the program will again ask how the user would like to interact with the cat. If the user enters 'n', the program will end. The user can enter either a capital letter or a lowercase letter. Below is a screenshot of expected result from running the program. Compare your nal result with the screenshot to verify. Look for small things such as upper or lower cases or extra white spaces, etc. Python 3.9.4 (v3.9.4:1f2e3088f3, Apr 4 2021, 12:32:44) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license()" for more information. >>> == RESTART: /Users/zli8/Desktop/Programming Assignment 2/main.py Please enter the name of your cat: Blossom How would you like to interact with Blossom? Enter 'play' or 'feed': play Blossom says meow Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': play Blossom says meow Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': play Blossom is tired. Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': feed Blossom says nom Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': feed Blossom says nom Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': feed Blossom is full. Would you like to continue? y/n: n Goodbye! >>> | write a Cat class so that you can make a cat object and interact with it. Make a class Cat. This class should have the following: • A name attribute that is intialized when a cat is created. • An energy attribute that has an initial value of 2. • A stomach capacity attribute that has an initial value of 2. • A method called play(). If the value of energy is greater than 0, it prints a message similar to "catname says meow" and then reduces the value of energy by 1. The message has to contain the name of the cat and the sound meow. However, if the value of energy is less than or equal to 0, it prints "catname is tired" instead. • A method called eat(). If the capacity of stomach is greater than 0, it prints a message similar to "catname says nom" and then reduces the capacity of stomach by 1. The message has to contain the name of the cat and the sound nom. However, if the capacity of stomach is less than or equal to 0, it prints "catname is full" instead. In main(), you should have the following: • The program asks the user to enter a name and then creates a cat object with that name. • The program then asks how the user would like to interact with the cat by entering either 'play' or 'feed' . Once the user enters the option, the program calls the corresponding methods from the Cat class to perform the interaction. Once the interaction is completed, the program should ask if the user would like to continue. If the user enters 'y, the program will again ask how the user would like to interact with the cat. If the user enters 'n', the program will end. The user can enter either a capital letter or a lowercase letter. Below is a screenshot of expected result from running the program. Compare your nal result with the screenshot to verify. Look for small things such as upper or lower cases or extra white spaces, etc. Python 3.9.4 (v3.9.4:1f2e3088f3, Apr 4 2021, 12:32:44) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license()" for more information. >>> == RESTART: /Users/zli8/Desktop/Programming Assignment 2/main.py Please enter the name of your cat: Blossom How would you like to interact with Blossom? Enter 'play' or 'feed': play Blossom says meow Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': play Blossom says meow Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': play Blossom is tired. Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': feed Blossom says nom Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': feed Blossom says nom Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': feed Blossom is full. Would you like to continue? y/n: n Goodbye! >>> | write a Cat class so that you can make a cat object and interact with it. Make a class Cat. This class should have the following: • A name attribute that is intialized when a cat is created. • An energy attribute that has an initial value of 2. • A stomach capacity attribute that has an initial value of 2. • A method called play(). If the value of energy is greater than 0, it prints a message similar to "catname says meow" and then reduces the value of energy by 1. The message has to contain the name of the cat and the sound meow. However, if the value of energy is less than or equal to 0, it prints "catname is tired" instead. • A method called eat(). If the capacity of stomach is greater than 0, it prints a message similar to "catname says nom" and then reduces the capacity of stomach by 1. The message has to contain the name of the cat and the sound nom. However, if the capacity of stomach is less than or equal to 0, it prints "catname is full" instead. In main(), you should have the following: • The program asks the user to enter a name and then creates a cat object with that name. • The program then asks how the user would like to interact with the cat by entering either 'play' or 'feed' . Once the user enters the option, the program calls the corresponding methods from the Cat class to perform the interaction. Once the interaction is completed, the program should ask if the user would like to continue. If the user enters 'y, the program will again ask how the user would like to interact with the cat. If the user enters 'n', the program will end. The user can enter either a capital letter or a lowercase letter. Below is a screenshot of expected result from running the program. Compare your nal result with the screenshot to verify. Look for small things such as upper or lower cases or extra white spaces, etc. Python 3.9.4 (v3.9.4:1f2e3088f3, Apr 4 2021, 12:32:44) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license()" for more information. >>> == RESTART: /Users/zli8/Desktop/Programming Assignment 2/main.py Please enter the name of your cat: Blossom How would you like to interact with Blossom? Enter 'play' or 'feed': play Blossom says meow Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': play Blossom says meow Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': play Blossom is tired. Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': feed Blossom says nom Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': feed Blossom says nom Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': feed Blossom is full. Would you like to continue? y/n: n Goodbye! >>> | write a Cat class so that you can make a cat object and interact with it. Make a class Cat. This class should have the following: • A name attribute that is intialized when a cat is created. • An energy attribute that has an initial value of 2. • A stomach capacity attribute that has an initial value of 2. • A method called play(). If the value of energy is greater than 0, it prints a message similar to "catname says meow" and then reduces the value of energy by 1. The message has to contain the name of the cat and the sound meow. However, if the value of energy is less than or equal to 0, it prints "catname is tired" instead. • A method called eat(). If the capacity of stomach is greater than 0, it prints a message similar to "catname says nom" and then reduces the capacity of stomach by 1. The message has to contain the name of the cat and the sound nom. However, if the capacity of stomach is less than or equal to 0, it prints "catname is full" instead. In main(), you should have the following: • The program asks the user to enter a name and then creates a cat object with that name. • The program then asks how the user would like to interact with the cat by entering either 'play' or 'feed' . Once the user enters the option, the program calls the corresponding methods from the Cat class to perform the interaction. Once the interaction is completed, the program should ask if the user would like to continue. If the user enters 'y, the program will again ask how the user would like to interact with the cat. If the user enters 'n', the program will end. The user can enter either a capital letter or a lowercase letter. Below is a screenshot of expected result from running the program. Compare your nal result with the screenshot to verify. Look for small things such as upper or lower cases or extra white spaces, etc. Python 3.9.4 (v3.9.4:1f2e3088f3, Apr 4 2021, 12:32:44) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license()" for more information. >>> == RESTART: /Users/zli8/Desktop/Programming Assignment 2/main.py Please enter the name of your cat: Blossom How would you like to interact with Blossom? Enter 'play' or 'feed': play Blossom says meow Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': play Blossom says meow Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': play Blossom is tired. Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': feed Blossom says nom Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': feed Blossom says nom Would you like to continue? y/n: y How would you like to interact with Blossom? Enter 'play' or 'feed': feed Blossom is full. Would you like to continue? y/n: n Goodbye! >>> |
Expert Answer:
Related Book For
Modern Systems Analysis And Design
ISBN: 9780134204925
8th Edition
Authors: Joseph Valacich, Joey George
Posted Date:
Students also viewed these programming questions
-
The matrix that rotates the axis vectors (1, 0) and (0, 1) through an angle is Q. What are the coordinates (a, b) of the original (1, 0) using the new (rotated) axes? This inverse can be tricky. Draw...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
Clara Hughes, who is pushing 5 0 , has medaled both in speedskating and road cycling ( and showing no signs of slowing down ) completed a training event where she biked 5 0 km east, stopped and rode...
-
You want a pot of water to boil at 105oC. How heavy a lid should you put on the 15 cm diameter pot when Patm = 101 kPa?
-
Danielle does not understand why a note receivable is not immediately recorded at its maturity amount (principal plus interest), rather than its principal amount. Aft er all, you know you are going...
-
Gavin Jones is inquisitive and determined to learn both the theory and the application of investment theory. He pressed the tree farmer for additional information and learned that it was possible to...
-
Craft Ltd. held 80% of the outstanding ordinary shares of Delta Corp. as at December 31, Year 12. In order to establish a closer relationship with Nonaffiliated Corporation, a major supplier to both...
-
22 Ibm of air under atmospheric pressure occupies a volume of 293 ft. What is the temperature of the air at that condition
-
Data on U.S. retail sales are available at the U.S. Bureau of the Census Internet site at: www.census.gov/retail/index.html. Under the heading "Monthly Retail Trade Report" there is a file titled...
-
Duncan had revenues of $380,000 in March. Fixed costs in March were $76,000 and profit was $114,000. a. What was the contribution margin percentage? Contribution Margin % b. What monthly sales volume...
-
4. Consider the IVP t y +1 y(0) = yo- (a) Without solving, determine all values of yo for which the IVP is certain to have a unique solution. (b) Solve the IVP for all such values of yo and detemine...
-
Northwood Company manufactures basketballs. The company has a ball that sells for $ 2 5 . At present, the ball is manufactured in a small plant that relies heavily on direct labor workers. Thus,...
-
At the beginning of 2 0 2 4 , VHF Industries acquired a machine with a fair value of $ 6 , 0 7 4 , 7 0 0 by signing a four - year lease. The lease is payable in four annual payments of $ 2 million at...
-
Suppose a couple in their early 30s is planning to buy a new HDB flat. The selling price of the HDB flat is $350,000. The couple has sufficient cash to make a down-payment of $35,000 (from CPF and...
-
1. Calculate the Payback Period of each project. Explain what argument Tim should make to show that the Payback Period is not appropriate in this case. 2. Calculate the Discounted Payback Period...
-
Q. X(S) = 153 54+55-2 of the Find the initial value signal.
-
An educational researcher devised a wooden toy assembly project to test learning in 6-year-olds. The time in seconds to assemble the project was noted, and the toy was disassembled out of the childs...
-
Describe the activities performed by the project manager during project planning.
-
What is a written use case and how does it compare to a use case diagram?
-
Draw an E-R diagram to represent the sample customer order in Figure 8-4. Figure 8-4. PVF CUSTOMER ORDER ORDER NO: 61384 CUSTOMER NO: 1273 NAME: Contemporary Designs 123 Oak St. Austin, TX 28384...
-
Draw and explain the class diagram for stable analysis pattern? Identify and highlight all participants and explain why they exist.
-
List some design and implementation issues faced, when implementing this pattern. Explain each issue.
-
List some differences between the analysis pattern described here and the traditional pattern.
Study smarter with the SolutionInn App