Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

using python 3 uppose a class called Room has already been created with private

ID: 3606895 • Letter: U

Question

using python 3

uppose a class called Room has already been created with private attributes roomNum and capacity.

An end-user of the class wants to create a Room object called chemLab which has room number 101 and capacity 50.
Show the Python statement they would use to do this.

2.

Suppose you are creating a new class called Employee with a private attribute hours.

Show the code for the method which will store a new value into the hours attribute.

NOTE: only provide the code for ONE method here -- do not write the code for the entire Employee class!

3.

Suppose you are creating a new class called Employee with a private attribute for hours.

Show the code for the method which will RETRIEVE the hours.

NOTE: only provide the code for ONE method here -- do not write the code for the entire Employee class!

4.

uppose a class called Book has been defined. Private members include bookID, title, and author.

Suppose the following statements appear in a program that imports the Book class:
myBook  = Book("A100", "The Forest", "Joe Smith")
print(myBook)   #output is ID: A100 Title: The Forest Author: Joe Smith


Write the method that MUST be in the Book class to make the output look like that.

NOTE: do NOT write the entire Book class -- you don't need to write the constructor method, for example. ONLY write the method that will produce the output shown for the print(myBook) statement.

Explanation / Answer

1) Suppose Room class created as below

class Room:

def __init__(self, roomNum, capacity):

2)

class Employee:

def __init__(self, hours):

3)

class Employee:

def __init__(self, hours):

Employee_value = Employee(100)

4)