Lab Assignment 3 (1)
Lab Assignment 3 (1)
3:
This assignment covers generics and multithreading. It is out of 30 marks, 20 for question
1 and 10 marks for question 2. You must complete your answer using the IntelliJ template
provided. In both questions the style and quality of your code will be taken into
consideration when allocating marks.
Inside the template is an interface called MiniList. MyMiniList must implement this
interface and be implemented with a single generic type.
Also included in the template is a simple set of tests for you to verify your implementation
against. You will receive the following marks for correctly implementing each of the
interfaces methods and a constructor.
Your class will need two instance variables, 1 for the current size of the list (an int) and an
array of generic type T to store the elements of the list call this objectStore.
Initially, set the size of this array to be 10. Also set your size variable to be 0.
This estimate only works because we have thrown a lot of darts. Rewrite the application
so that it can be run across multiple threads. You answer should include the following:
Origin 0,0
fi
fi
fi
• A TotalWithin class that keeps track of the number of darts that are within the dart board
• A class that extends Thread which throws darts, works out their distance from the origin
and increases the value held within TotalWithin if needed.
• Test your programme with 4 threads running and get an estimate of pi based on 1 billion
darts.