Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to finish the body of the code for the total_payall method. Right now it runs correctly if pay_all is called only once. How

image text in transcribed

I need to finish the body of the code for the total_payall method. Right now it runs correctly if pay_all is called only once. How can I get it to work if pay_all is called multiple times?

Also, the problem says that I should be able to solve it without adding any attributes.

Pep.py quizz.py # Part 2 # In this part of the prep, you will be implementing the total_payroll method # of the Company class. # 29 # You should not need to add any additional attributes to the class in order # to be able to write this method. 30 31 02 Eclass Company: "A company with employees. 03 04 05 We use this class mainly as a client for the various Employee classes we defined in employee. 06 07 08 === Attributes === employees: the employees in the company. 09 NI 10 A 11 employees: List[Employee] 12 13 def __init__(self, employees: List[Employee)) -> None: self.employees = employees A 14 15 16 17 def pay_all(self, pay_date: date) -> None: "Pay all employees at this company.""" for employee in self.employees: employee.pay (pay_date) def total_payroll(self) -> float: "Return the total of all payments ever made to all employees. -18 19 20 221 222 223 224 225 226 227 228 229 230 231 232 233 A >>> my_corp = Company ([\ SalariedEmployee(24, 'Gilbert the cat', 1200.0), \ HourlyEmployee(25, 'Chairman Meow', 500.25, 1.0)]) >>> my_corp.pay_all(date (2018, 6, 28)) An employee was paid 100.0 on 2018-06-28. An employee was paid 500.25 on 2018-06-28. >>> my_corp.total_payroll() 600.25 234 total = 0 for employee in self.employees: total += employee,get_monthly payment() 235 236 237 238 return total 30

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions