Professional Documents
Culture Documents
Week 5 Assignment Nov
Week 5 Assignment Nov
'''employee ID, employee name, employee worked hours and employee pay rate,'''
accessors methods for employee ID, employee name, employee worked hours and
'''b) Create a method get_total_pay that calculates and returns the total pay of an employee.
'''Create an __str__ method representing an employee data in this format: Name: Thair
Dalain, Worked hours: 30, Pay rate: $100, Total pay: $300'''
class Employee:
self.ID=ID
self.name=name
self.worked_hours=worked_hours
self.pay_rate=pay_rate
def get_ID(self):
return self.ID
def get_name(self):
return self.name
def get_worked_hours(self):
return self.worked_hours
def get_pay_rate(self):
return self.pay_rate
def get_total_pay(self):
return self.worked_hours*self.pay_rate
def __str__(self):
'''d) In your main() function, instantiate the employee class for two different employees
with some dummy data and print out those instances using print() calls '''
def main():
print(E1)
print(E2)
main()
Q2
a) Create a Book class that holds these attributes: ISBN, title, author, publish year, book
status. Since books can have a different status, the book status should be a list of strings,
b) Create accessor methods for all attributes and create a mutator to update the book title.
c) Create another program and import the Book class to it. This program creates one or
more book objects with any sample data and then prints out those instances using
accessor methods.
'''
class book:
self.ISBN = ISBN
self.title = title
self.author =author
self.year = year
self.status = status
def get__ISBN(self):
return self.ISBN
def get__tittle(self):
return self.tittle
def get__author(self):
return self.author
def get__year(self):
return self.year
def get__status(self):
return self.status
def set_title(self,T2):
self.title = T2
B2.set_title("java")
print (B2.tittle)