Starting Out with Python plus MyProgrammingLab with Pearson eText -- Access Card Package (3rd Edition)
bartleby

Videos

Textbook Question
100%
Book Icon
Chapter 10, Problem 1PE

Pet Class

The Pet class

Write a class named Pet, which should have the following data attributes:

■ _ _ name (for the name of a pet)

■ _ _ animal_type (for the type of animal that a pet is. Example values are 'Dog', 'Cat', and 'Bird’)

■ _ _ age (for the pet’s age)

The Pet class should have an _ _init_ _ method that creates these attributes. It should also have the following methods:

■ set_name

This method assigns a value to the _ _name field.

■ set_animal_type

This method assigns a value to the _ _animal_type field.

■ set_age

This method assigns a value to the _ _age field.

■ get_name

This method returns the value of the _ _name field.

■ get_animal_type

This method returns the value of the _ _animal_type field.

■ get_age

This method returns the value of the _ _age field.

Once you have written the class, write a program that creates an object of the class and prompts the user to enter the name, type, and age of his or her pet. This data should be

stored as the object’s attributes. Use the object's accessor methods to retrieve the pet’s name, type, and age and display this data on the screen.

Blurred answer
03:32
Students have asked these similar questions
(Invoice Class) Create a class called Invoice that a hardware store might use to representan invoice for an item sold at the store. An Invoice should include four data members—a part number (type string), a part description (type string), a quantity of the item being purchased (typeint) and a price per item (type int). Your class should have a constructor that initializes the fourdata members. A constructor that receives multiple arguments is defined with the form:ClassName( TypeName1 parameterName1, TypeName2 parameterName2, ... )Provide a set and a get function for each data member. In addition, provide a member functionnamed getInvoiceAmount that calculates the invoice amount (i.e., multiplies the quantity by theprice per item), then returns the amount as an int value. If the quantity is not positive, it should beset to 0. If the price per item is not positive, it should be set to 0. Write a test program that demonstrates class Invoice’s capabilities
Problem: Employee and ProductionWorker Classes Write a python class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: • Shift number (an integer, such as 1, 2, or 3)• Hourly pay rateThe workday is divided into two shifts: day and night. The shift attribute will hold an integer value representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2. Write the appropriate accessor and mutator methods for this class. Once you have written the class, write a program that creates an object of the ProductionWorker class, and prompts the user to enter data for each of the object’s data attributes. Store the data in the object, then use the object’s accessor methods to retrieve it and display it on the screen   Note: The program should be written in python.     Sample Input/Output: Enter the name: Ahmed Al-AliEnter the ID number: 12345Enter the department:…
C++ Code: Goal: Write a Class to represent Fractions Write a Fraction class whose objects will represent fractions. For example, a fraction of 3/7 will be represented by a Fraction object whose numerator will be set to 3 and denominator will be set to 7. Implementation Note: For this checkpoint do not reduce fractions (i.e. 15/18 should NOT be reduced to 5/6), do not use "const" (since we haven't discussed in class yet)  Attributes: Your class should have exactly two private data members, one to represent the numerator of the Fraction being represented, and one to represent the denominator of the Fraction being represented. (What should be the data type of these member variables?) Member functions: A default constructor that sets the fraction to 0 (what should be the numerator and denominator for such a fraction?). A parametrized constructor takes two integer arguments, a numerator and a denominator, and assigns the attributes accordingly. Arithmetic operations that add,…

Chapter 10 Solutions

Starting Out with Python plus MyProgrammingLab with Pearson eText -- Access Card Package (3rd Edition)

Ch. 10.4 - What is an object?Ch. 10.4 - Prob. 2CPCh. 10.4 - Why is an object's internal data usually hidden...Ch. 10.4 - What are public methods? What are private methods?Ch. 10.4 - Prob. 15CPCh. 10.4 - Prob. 16CPCh. 10.4 - When designing an object-oriented application, who...Ch. 10.4 - How do you identify the potential classes in a...Ch. 10.4 - What are a classs responsibilities?Ch. 10.4 - What two question should you ask to determine a...Ch. 10.4 - Will all of a class's action always be directly...Ch. 10 - The _______ programming practice is centered on...Ch. 10 - The ___________ programming practice is centered...Ch. 10 - A(n) _____ is a component of a class that...Ch. 10 - Prob. 4MCCh. 10 - By doing this, you can hide a classs attribute...Ch. 10 - Prob. 6MCCh. 10 - A(n) ________ method stores a value in a data...Ch. 10 - Prob. 8MCCh. 10 - If a class has a method named _ _str_ _ , which of...Ch. 10 - A set of standard diagrams for graphically...Ch. 10 - In one approach to identifying the classes in a...Ch. 10 - Prob. 12MCCh. 10 - The practice of procedural programming is centered...Ch. 10 - Object reusability has been a factor in the...Ch. 10 - It is a common practice in object-oriented...Ch. 10 - Prob. 4TFCh. 10 - Starting an attribute name with two underscores...Ch. 10 - You cannot directly call the _ _ str _ _ method.Ch. 10 - One way to find the classes needed for an...Ch. 10 - Prob. 1SACh. 10 - Why should an object's data attributes be hidden...Ch. 10 - What is the difference between a class and an...Ch. 10 - The following statement calls an object's method....Ch. 10 - Prob. 5SACh. 10 - In a Python class, how do you hide an attribute...Ch. 10 - Prob. 7SACh. 10 - Suppose my_car is the name of a variable that...Ch. 10 - Prob. 2AWCh. 10 - Look at the following description of a problem...Ch. 10 - Pet Class The Pet class Write a class named Pet,...Ch. 10 - Car Class Write a class named Car that has the...Ch. 10 - Personal Information Class Design a class that...Ch. 10 - Employee Class Write a class named Employee that...Ch. 10 - RetailItem Class Write a class named RetailItem...Ch. 10 - Employee Management System This exercise assumes...Ch. 10 - Cash Register This exercise assumes you have...Ch. 10 - Trivia Game In this programming exercise, you will...
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
C++ Data Members; Author: CppNuts;https://www.youtube.com/watch?v=StlsYRNnWaE;License: Standard YouTube License, CC-BY