Question: Write PYTHON code for this problem. This should be Object Oriented Solution. Write two Classes for this problem. Class Task: Class Worker: Problem Statement

Write PYTHON code for this problem.

This should be Object Oriented Solution.

Write two Classes for this problem.

Class Task:

Class Worker:

""" Problem Statement customers send us collections of data over the course of each week. Lets call each unit of data a task. We send these tasks to our work force for labeling. When these tasks are labeled, we send them back to the customer.

Each task goes through three sequential stages:

L0 L1 L2

A task is only complete when it reaches the L2 stage and work is finished on the L2 stage

Notes: - There is a 1:1 mapping between task stages and workers working on a task stage. (i.e Task X L1 can only have 1 worker at one time, that worker cannot be working on anything else) - A worker can only work on a task if the worker has never worked on that task before. - For now, assume each worker takes 1 timestep. We may change this later. - Tasks should be greedily assigned to any free workers who can work on the task.

Write a system that simulates the environment and runs until all tasks are completed. Do not worry about runtime, we are looking for correctness. On every timestep where activity happens: Print out the timestep, and all the activities that happened. (worker assignment/completion). At the end, print out the total number of time steps taken to complete the simulation.

This is the input

Sample input 1: tasks = [Task('A')] workers = [Worker('X'), Worker('Y'), Worker('Z')]

This is the output look like

Sample output 1: 0 Assigning X to Task A for L0 1 Worker X finished Task A for L0 Assigning Y to Task A for L1 2 Worker Y finished Task A for L1 Assigning Z to Task A for L2 3 Worker Z finished Task A for L2 Total time taken: 3 ts

Sample input 2: tasks = [Task('A'), Task('B')] workers = [Worker('X'), Worker('Y'), Worker('Z')]

Sample output 2: 0 Assigning X to Task A for L0 Assigning Y to Task B for L0 1 Worker X finished Task A for L0 Worker Y finished Task B for L0 Assigning Z to Task A for L1 Assigning X to Task B for L1 2 Worker Z finished Task A for L1 Worker X finished Task B for L1 Assigning Y to Task A for L2 Assigning Z to Task B for L2 3 Worker Y finished Task A for L2 Worker Z finished Task B for L2 Total time taken: 3 ts

Class Task:

#Implement

Class Worker:

#Implement

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!