CS51 - Fall 2009 - Lecture 4
- Write the instructions for creating and positioning a 50 by 50 pixel FramedRect so that it is centered in any window.
- Write the instructions for creating a Text object, that says "I am centered" and positions it so that it is centered in any window.
basketball demo and code
better basketball demo
- what do we need to change?
- instance variables
- ball (oval, location and size)
- how do we move the ball? (hint: think about scribble)
- onMousePress - see if we're inside the ball
- keep track of this somehow
- boolean variables
- check if we're holding the ball
- if so, move the ball (how do we do this?)
- check if we're carrying the ball
- check if we're inside the hoop
- if both true
- update score
- update display
- what about the position of the ball?
- nested if statements
- this seems awkward? What question are we asking here?
- AND ('&&') and OR ('||')
- change code
- what is the difference between this version and scribbler?
- randomly picking colors
- RandomIntGenerator class
- specify range inclusive in constructor
- nextValue() method gives you a random integer in range
- set the color each time we click
- pick a random integer between 1 and 4
- if-else statement?
- keep track of which color we're current using
- set the color of the line to the current color we're using