Skip to document

Assignment 4 - Lecture notes 5

notes
Course

Computer Science (CSC1B)

103 Documents
Students shared 103 documents in this course
Academic year: 2021/2022
Uploaded by:
Anonymous Student
This document has been uploaded by a student, just like you, who decided to remain anonymous.
University of Johannesburg

Comments

Please sign in or register to post comments.

Preview text

Computer Science 3A

Practical Assignment 4

10 March 2022

Time: 10 March 2022 Ů 17h00 Marks: 50

Practical assignments must be uploaded toeve.uj.ac before 17h00. Late submissions will not be accepted , and will therefore not be marked. You are not allowed to collabo- rate with any other student.

You manage to land your Ąrst developer job. Life is good! The problem is that for the next 6 months or so you are probably going to do a graduate program or do bug Ąxing on existing systems :( Is it fair? Well many people argue that it makes new developers more familiar with current systems. Another issue is that some companies explicitly giving bug Ąxes to newer staff and that may not be fair because these developers would be overloaded. This practical is all about making that allocation of bug Ąxes more fair in an efficient way.

Every developer has a limited amount of energy to facilitate bug Ąxes and not every de- veloper is created equal, which results in a difficult problem to resolve. How are they each allocated fairly? How do we determine what is fair? Enter queues. Their job is to ensure that each entity gets fair treatment and everything progresses in a linear order.

For this weekŠs practical we are going to deal with this problem in the form of Develop- ers and BugFixes. Developers perform BugFixes that are allocated to them and use up energy to perform the Ąx (or a part thereof). You need to implement a Queue-based allocator that ensures the work of the BugFixes are spread evenly among Developers and the Developers are not overworked.

You are required to implement the following functions:

  • enqueue - that inserts an element into the queue.

  • dequeue - that removes an element from the queue.

  • front - the methods that returns the front element in the queue.

  • allocateDevelopersRandomly - A method that allocates Developers by random and decreases their energy level by their respective work rate. In every iteration a random Developer is chosen for work until each BugFix in order is completed. This method should display the time it took to complete the allocation.

Computer Science 3A Practical Assignment 4 10 March 2022

  • allocateDevelopersWithQueue - The methods that allocates BugFixes by iterating through Developers using an array and according to their work rate energy levels are depleted, along with the work for that respective BugFix. it allocates BugFixes to Developers according to their energy levels using a queue for the Developers. This method should display the time it took to complete the allocation.

You are required to implement a Java Program that realises the above operations. The output for one function looks similar to:

Name: Developer 0 WR: 19 Energy: 100 Name: Developer 1 WR: 14 Energy: 100 Name: Developer 2 WR: 9 Energy: 100 Name: Developer 3 WR: 1 Energy: 100 Name: Developer 4 WR: 10 Energy: 100 Name: Developer 5 WR: 14 Energy: 100 Name: Developer 6 WR: 19 Energy: 100 Name: Developer 7 WR: 19 Energy: 100 Name: Developer 8 WR: 1 Energy: 100 Name: Developer 9 WR: 11 Energy: 100 Name: Bug Fix 0 work: 0 of: 28 Name: Bug Fix 1 work: 0 of: 48 Name: Bug Fix 2 work: 0 of: 46 Name: Bug Fix 3 work: 0 of: 18 Name: Bug Fix 4 work: 0 of: 20 Name: Bug Fix 5 work: 0 of: 39 Name: Bug Fix 6 work: 0 of: 23 Name: Bug Fix 7 work: 0 of: 56 Name: Bug Fix 8 work: 0 of: 60 Name: Bug Fix 9 work: 0 of: 4

Allocation by Random: Bug Fix 0 at 32% Developer 6 Energy at: 81 Bug Fix 0 at 35% Developer 2 Energy at: 99 Bug Fix 0 completed Developer 0 Energy at: 81 Bug Fix 1 at 2% Developer 8 Energy at: 81 Bug Fix 1 at 31% Developer 5 Energy at: 86 Bug Fix 1 at 68% Developer 4 Energy at: 90 Bug Fix 1 completed Developer 0 Energy at: 81 Omitted**

Computer Science 3A Practical Assignment 4 10 March 2022

Bonus

Modify the allocateDevelopersWithQueue method in a method called allocateDevelopersWith- QueueWithBreaks to accommodate Developers that take a break when tired and for every iteration in a break state they gain 20 energy. In order to test the bonus, there needs to be a 100 BugFixes instead of 10. This method should display the time it took to complete the allocation.

Marksheet

  1. [3]Queue: enqueue

  2. [4]Queue: dequeue

  3. [3]Queue: front

  4. [15]Main: allocateDevelopersRandomly

  5. [15]Main: allocateDevelopersWithQueue

  6. [10]Compilation and Correct execution.

Was this document helpful?

Assignment 4 - Lecture notes 5

Course: Computer Science (CSC1B)

103 Documents
Students shared 103 documents in this course
Was this document helpful?
Computer Science 3A
Practical Assignment 4
10 March 2022
Time: 10 March 2022 Ů 17h00 Marks: 50
Practical assignments must be uploaded to eve.uj.ac.za before 17h00. Late submissions
will not be accepted, and will therefore not be marked. You are not allowed to collabo-
rate with any other student.
You manage to land your Ąrst developer job. Life is good! The problem is that for the
next 6 months or so you are probably going to do a graduate program or do bug Ąxing on
existing systems :( Is it fair? Well many people argue that it makes new developers more
familiar with current systems. Another issue is that some companies explicitly giving bug Ąxes
to newer staff and that may not be fair because these developers would be overloaded. This
practical is all about making that allocation of bug Ąxes more fair in an efficient way.
Every developer has a limited amount of energy to facilitate bug Ąxes and not every de-
veloper is created equal, which results in a difficult problem to resolve. How are they each
allocated fairly? How do we determine what is fair? Enter queues. Their job is to ensure that
each entity gets fair treatment and everything progresses in a linear order.
For this weekŠs practical we are going to deal with this problem in the form of Develop-
ers and BugFixes. Developers perform BugFixes that are allocated to them and use up
energy to perform the Ąx (or a part thereof). You need to implement a Queue-based allocator
that ensures the work of the BugFixes are spread evenly among Developers and the Developers
are not overworked.
You are required to implement the following functions:
enqueue - that inserts an element into the queue.
dequeue - that removes an element from the queue.
front - the methods that returns the front element in the queue.
allocateDevelopersRandomly - A method that allocates Developers by random and
decreases their energy level by their respective work rate. In every iteration a random
Developer is chosen for work until each BugFix in order is completed. This method
should display the time it took to complete the allocation.
Page 1 of 4