Question

In: Computer Science

Create automated Pizza Restaurant System which has the following details: a. A class Employee that has...

Create automated Pizza Restaurant System which has the following details: a. A class Employee that has attributes like name, date of joining, salary and a job description. b. An Employee can be a Server or a Chef. A Server gets a salary of 4000 AED and has a job description “customer interface”. A Chef gets a salary of 5000 AED and has a job description “makes food”. The restaurant also has a Pizza Robot that is a chef and has a salary of 0 AED and has a job description “makes pizza”. The robot has other attributes like manufacturer, date of manufacture, and next service date. c. Create a separate test module where instances of the class are created, and the methods are tested with appropriate instances for each and print the job description and salary for each employee, including the robot chef!

Solutions

Expert Solution

Question 1 :

CODE :

import datetime #importing library for date objects
class Employee: #Employee class which is the super class
def __init__(self,name,doj,salary,job_description):
self.name=name
self.doj=doj
self.salary=salary
self.job_description=job_description
  
def __str__(self): #To print the employee details will be inherited by all the subclasses
s="\nName : "+self.name+"\nDate of joining : "+str(self.doj)+"\nJob Description : "+self.job_description
s=s+"\nSalary : "+str(self.salary)+" AED"
return s
  
class Server(Employee): #Server is a type of employee so its the subclass of Employee
def __init__(self,name,doj): #only name and date of joining is given by user whereas the salary and job description is fixed
super().__init__(name, doj, 4000, 'customer interface')

class Chef(Employee): #Chef is a type of employee so its the subclass of Employee
def __init__(self,name,doj): #only name and date of joining is given by user whereas the salary and job description is fixed
super().__init__(name, doj, 5000, 'makes food')
  
class PizzaRobot(Employee): #A type of chef but super class will be employee because of the extra details
def __init__(self,name,doj,manufacturer,dom,service_date):
super().__init__(name, doj, 0, 'makes pizza') #Calling the Employee class constructor using super()
self.manufacturer=manufacturer
self.dom=dom
self.service_date=service_date
  
def set_service_date(self,sdate): #This is a setter function because the service dates will keep changing
self.service_date=sdate

def __str__(self): #to print details first print from the super class and then the extra details of PizzaRobot class
print(super().__str__())
return "Manufacturer : "+self.manufacturer+"\nDate of manufacture : "+str(self.dom)+"\nService Date : "+str(self.service_date)
  
#Test 1 where a Server is created and printed using __str__()
s1=Server("Mary Fonollonsa",datetime.date(2020,5,16))
print(s1.__str__())

#Test 2 where a Chef is created and printed using __str__()
c1=Chef("Esther Romando",datetime.date(2020,6,12))
print(c1.__str__())

#Test 3 where a PizzaRobot is created and printed using __str__()
p1=PizzaRobot("Robot 1.5X",datetime.date(2018,4,30),"TDX Robotics Inc.",datetime.date(2017,4,30),datetime.date(2018,12,1))
print(p1.__str__())

##Test 4 where an Employee is created and printed using __str__()
e1=Employee("Ronaldo Vinci",datetime.date(2019,12,30),6000,"Manager")
print(e1.__str__())

CODE Screenshots :

OUTPUT :

Explanation of the code :

The code is about object oriented programming that is why there are 4 classes in the code and inheritance concept have been used.

The super class is the Employee with 4 fields. Now for Employee type Server and Chef the 2 fields are fixed i.e. salary and job description. So, these 2 classes are the subclasses of the Employee.

Then come the PizzaRobot class which is mentioned as the chef but also has 2 things fixed i.e. salary and job description. So instead of inheriting from the Chef class, it has been inherited from the Employee. IT also has some other fields which are taken care of by self variables.

All the information of the classes are printed by using __str__() functions. Since, Employee is the super class all its methods are inherited by its subclasses so, the __str__() function is present in the Employee class.

But PizzaRobot class has more new self variables and to print that it has its own __str__(). It first calls and prints the super() class i.e. Employee class __str__() because half information is already printable by using it and then rest of it is printed using its own __str__() function.


Related Solutions

Create a class called employee which has the following instance variables: Employee ID number Salary Years...
Create a class called employee which has the following instance variables: Employee ID number Salary Years at the company Your class should have the following methods: New employee which reads in an employee’s ID number, salary and years of service Anniversary which will up the years of service by 1 You got a raise which will read in how much the raise was (a percent) and then calculate the new salary You get a bonus which gives a yearly bonus...
Create a C# Application. Create a class object called “Employee” which includes the following private variables:...
Create a C# Application. Create a class object called “Employee” which includes the following private variables: firstN lastN idNum wage: holds how much the person makes per hour weekHrsWkd: holds how many total hours the person worked each week regHrsAmt: initialize to a fixed amount of 40 using constructor. regPay otPay After going over the regular hours, the employee gets 1.5x the wage for each additional hour worked. Methods: constructor properties CalcPay(): Calculate the regular pay and overtime pay. Create...
Which of the following is an example of an accrual-based expense for a pizza restaurant? a....
Which of the following is an example of an accrual-based expense for a pizza restaurant? a. The cash purchase of a delivery truck b. The cash purchase of pizza ingredients to be used in the next accounting period c. The cash and account purchases of pizza ingredients that have been used to make pizzas during the current accounting fiscal period d. The recognition of a note payable to borrow cash for ongoing operations
C++ Write a program to create a linked list which stores the details of employees(Employee number,...
C++ Write a program to create a linked list which stores the details of employees(Employee number, employee name, rate, hours worked). Create a menu to manage the emoployee data. MENU 1. ADD EMPLOYEE DETAILS 2. DELETE EMPLOYEE 3. SEARCH EMPLOYEE 4. PRINT EMPLOYEE PAYROLL 5. EXIT When the user selected option #4 the program should print the following pay report for each employee: EmpNo.     Name      Rate    Hours    Regular Pay      Overtime Pay     Gross Pay Any hours worked above 40 hours are...
The Account class Create a class named Account, which has the following private properties:
in java The Account class Create a class named Account, which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNumber (), getBalance (), setBalan newBalance). There is no setNumber () once an account is created, its account number cannot change. Now implement these methods: void deposit (double amount) and void withdraw (double amount). For both these methods, if the amount is less than...
The Account class Create a class named Account , which has the following private properties:
 The Account class Create a class named Account , which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNunber(), getBalance(), setBalance (double newBalance) . There is no setNunber() - once an account is created, its account number cannot change. Now implement these methods: void deposit (double anount) and void withdraw(double anount). For both these methods, if the amount is less than zero,...
in JAVA PLEASE SHOW OUTPUT! PriorityQueueUserDefinedObjectExample (20) Create an Employee class which implements Comparable<Employee> The constructor...
in JAVA PLEASE SHOW OUTPUT! PriorityQueueUserDefinedObjectExample (20) Create an Employee class which implements Comparable<Employee> The constructor consists of an employee’s first name and an employee’s salary, both of which are instance variables. Create accessor and mutator methods for both of these variables Write an equals method that returns true if the salaries are equal with one cent and the names are exactly equal Write a compareTo method that returns 1 if the salary of this employee is greater than the...
The Best of Italy Pizza Restaurant make pizza for in-house and on-line customers. The company has...
The Best of Italy Pizza Restaurant make pizza for in-house and on-line customers. The company has two direct-cost categories: direct materials and direct manufacturing labor. Variable manufacturing overhead is allocated to products on the basis of standard direct manufacturing labor-hours. Following is some budget data for the Best of Italy Pizza: Direct manufacturing labor use 0.42 hours per pizza Variable manufacturing overhead $4.00 per direct manufacturing labor-hour The Best of Italy Pizza Company provides the following additional data for the...
The Best of Italy Pizza Restaurant make pizza for in-house and on-line customers. The company has...
The Best of Italy Pizza Restaurant make pizza for in-house and on-line customers. The company has two direct-cost categories: direct materials and direct manufacturing labor. Variable manufacturing overhead is allocated to products on the basis of standard direct manufacturing labor-hours. Following is some budget data for the Best of Italy Pizza: Direct manufacturing labor use 0.42 hours per pizza Variable manufacturing overhead $4.00 per direct manufacturing labor-hour The Best of Italy Pizza Company provides the following additional data for the...
The Account class Create a class named Account, which has the following private properties: number: long...
The Account class Create a class named Account, which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNumber(), getBalance(), setBalance(double newBalance). There is no setNumber() -- once an account is created, its account number cannot change. Now implement deposit(double amount) and withdraw(double amount) methods. If the amount is less than zero,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT