PA6_Recurrence

Java important constants numofimages should be used

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1_TICKS + 6; static final int WHEEL_3_TICKS = WHEEL_2_TICKS + 6; static final int WHEEL_1_DELAY = 100; static final int WHEEL_2_DELAY = WHEEL_1_DELAY + 25; static final int WHEEL_3_DELAY = WHEEL_2_DELAY + 25; Slots.java Important constants: NUM_OF_IMAGES - should be used to define the size of the array holding your images IMAGE_WIDTH, SPACE_BETWEEN_WHEELS, and WHEELS_Y_OFFSET - use them to define the location of where you are placing your slot wheels WHEEL_X_TICKS, WHEEL_X_DELAY - controls the slot wheel’s speed (1 > 2 > 3), pass these into your slot wheel constructor Slots Slots will have one method, begin(): 0. Create a header and footer panel, header should hold the JLabel for the title, and footer should hold the spin button 1. Initialize an image array containing all the half and full images in order 2. Dynamically calculate wheel locations at start-up based on canvas width 3. Create new slot wheels using these locations and image array 4. Register each slot wheel as a listener for events on the spin button SlotWheel Constructor public SlotWheel( Image pics, int ticks, int delay, Location location, DrawingCanvas canvas ) { //set appropriate instance variables } SlotWheel •  Make sure you create instance variables •  to keep track of the parameters passed into the constructor Some instance variables to keep track of: private FramedRect slotWheelBorder; private RandomDoubleGenerator rand; private VisibleImage slotWheel; What others do you need to keep track of? synchronized(this){...} - Use Java synchronization blocks to avoid half images! - Why do we need this? run() thread and event handling thread are potentially running at the same time as independent threads - This allows...
View Full Document

Ask a homework question - tutors are online