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

Concept explainers

Question
Book Icon
Chapter 10, Problem 2AW
Program Plan Intro

Algorithm:

  • • Create a class named “Book”.

Part a: Defining “__init__” method

  • • Now define the “__init__()” method for the class. Inside the method,
    • ○ Assign the attribute for “book_title”.
    • ○ Assign the attribute for “author_name”.
    • ○ Assign the attribute for “publisher_name”.

Part b: Creating accessor and mutator methods:

  • • Define an accessor method named “set_book_title()”
    • ○ Now assign the attribute “book_title”.
  • • Define an accessor method named “set_author_name()”
    • ○ Now assign the attribute “author_name”.
  • • Define an accessor method named “set_publisher_name ()”
    • ○ Now assign the attribute “publisher_name”.
  • • Define the mutator method named “get_book_title()”
    • ○ Return the value for  “book_title”.
  • • Define the mutator method named “get_author_name ()”
    • ○ Return the value for  “author_name”.
  • • Define the mutator method named “get_publisher_name ()”
    • ○ Return the value for  “publisher_name”.

Part c: Defining the “__str__” method to return a string:

  • • Now define the “__str__()” method.
    • ○ Return the values for string variables.
  • • Create an object “object1” for the class “BOOK”.
  • • Now print the values using the “print” statement.

Blurred answer
Students have asked these similar questions
Create a class that represents an employee. This class will have three constructors to initialize variables. If the constructor doesn't provide a parameter for a field, make it either "(not set)" or "0" as appropriate. Name: Employee Fields: - name : String - idNumber : int - department : String - position : String Methods: + Employee() + Employee(name : String, idNumber : int) + Employee(name : String, idNumber : int, department : String, position : String) + getName() : String + getDepartment() : String + getPosition() : String + getIdNumber() : intEmployeeDemo.java Code public class EmployeeDemo{public static void printInfo(Employee e){System.out.println(e.getName() + ", " + e.getIdNumber() + ", " + e.getDepartment() + ", " + e.getPosition());}public static void main(String[] args){Employee e1 = new Employee();Employee e2 = new Employee("Bill Gates", 1975);Employee e3 = new Employee("Steve Jobs", 1976, "Design",…
Create a class that represents an employee. This class will have three constructors to initialize variables. If the constructor doesn't provide a parameter for a field, make it either "(not set)" or "0" as appropriate. Name: Employee Fields: - name : String - idNumber : int - department : String - position : String Methods: + Employee() + Employee(name : String, idNumber : int) + Employee(name : String, idNumber : int, department : String, position : String) + getName() : String + getDepartment() : String + getPosition() : String + getIdNumber() : int use test case as result
a) Create an enumeration named Departments that contain four set of values FINANCE, HR, IT, and MARKETING.b) Create a class named PersonDetails that contains fields for a person’s first name (String), last name (String), and address (String). The class have- A constructor that accepts parameters for each field.- Get methods for each field.c) Create a class named Employee that contains fields for an employee ID (int), Social Security number (String), personal information (Person object), department (Departments type), and annual salary (double). The class have- A constructor that requires values for each data field.- Get methods for each of the data fields.- Set methods for each of the data fields.d) Create an application/class named EmployeeSort that allows a user to enter values for an array of 5 Employee objects (create an array of Employee type that will save 5 employee objects). Prompt a user for the data needed to create an employee object. Continue to prompt the user for Social…

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
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT