Lab Exercise for Assignment 9
COMP112 2020 Tri 1: Lab Exercise 9
This assignment will give you more experience in developing programs that use
arrays and ArrayLists of objects.
Resources and links
Download the zip file for lab exercise 9 and extract it to the
folder in your home folder.
It should contain templates for the exercises program. Read through the exercises and run the demo so that you know what you need to do.
- Array Exercise.
Two methods which involve storing and manipulating values in arrays:
- Tile Exercise.
A program letting the user move Scrabble tiles around on a rack. This exercise is closely related to
The assignment involves two programs to submit:
- The first program analyses data about a collection of 4335 NZ earthquakes from May 2016 to May 2017.
- The second program lets a player play a simple solitaire dominoes game.
There is one exercise to give you practice with arrays and another exercise
) closely related to
Make sure that you do
TileExercise before starting the domino game program.
program has two methods to write:
is a little game with an array of five toy Duck objects.
The method should first of all set up the array of Ducks, then it should
ask the user to enter the index of a Duck to shoot. If that
duck is still in the array, the program should shoot the Duck, remove
it from the array, and make each remaining duck jiggle. Run the demo
to see how it works.
- A constructor with one double parameter, specifying the x position of the Duck on the screen.
jiggle method with no parameters that will make the duck jiggle up and down a few times. You shouldn't jiggle a dead duck.
shoot method with no parameters that will make the duck fall upside down.
should read all the scores in a file called
, and count them. Each score is an integer between 0 and
10 (inclusive). Your programme should count how many 0's, how many
1's, how many 2's, etc. It should use an array to keep the 11
different counts in. (For example, the count of how many 4's the
program has read should be stored at index 4 in the array).
- Construct a new array to hold the 11 counts.
- Read the scores in the file, increasing the appropriate count every time it reads a score.
- Print out all 11 counts.
program lets the user move Scrabble tiles around on
a rack. The rack is represented by an array of 7
class is written for you.) Part of the program is written
for you, including the fields,
method for drawing all the
method to let the user select the tiles and the
setting up of the GUI in the
have to complete the methods for the other buttons:
reset which should fill the array in the
tiles field with new
left which should move the currently selected tile one step to the left in the array (by swapping it with the tile on its left) and redrawing.
right which should move the currently selected tile one step to the right in the array (by swapping it with the tile on its right) and redrawing.
remove which should remove the currently selected tile from the array, and redrawing.
method, which is written for you, allows the user to
select a Tile, and stores the index of the tile in the
field, which should be used in the methods that you write.