java.lang.Objectseminar.ObjectCreationPractice
public class ObjectCreationPractice
ObjectCreationPractice
is a game that someone beginning to learn ObjectDraw can use
to familiarize themselves with the basic object types and how to create them. The method
ObjectCreationPractice.show()
displays a pattern of five objects on the screen
for the programmer to try to write instructions to match. The method ObjectCreationPractice.test()
will actually verify whether the objects currently on the canvas match the desired pattern.
Each of these methods takes an int
parameter specifying which pattern to show
or test. The pattern that you are trying to match from show()
should be the same
number you ask the program to test
. The number of the pattern also controls the
difficulty:
FramedRect
and FilledRect
will be used,
with no color parameter.
FramedOval
and FilledOval
are now possible, but still
with no color parameter.
Color.RED
,
Color.GREEN
, Color.BLUE
, Color.YELLOW
, Color.CYAN
,
Color.MAGENTA
, Color.GRAY
, and Color.BLACK
.
Line
s are introduced.
FramedRoundedRect
and FilledRoundedRect
are introduced.
FramedArc
and FilledArc
are introduced.
Nested Class Summary | |
---|---|
static class |
ObjectCreationPractice.Pulsar
|
Constructor Summary | |
---|---|
ObjectCreationPractice()
|
Method Summary | |
---|---|
static void |
show(int n,
DrawingCanvas canvas)
Display a pattern of five objects that you can then attempt to write code to match. |
static void |
test(int n,
DrawingCanvas canvas)
Test to see whether the objects on the given canvas match a particular test pattern. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ObjectCreationPractice()
Method Detail |
---|
public static void show(int n, DrawingCanvas canvas)
n
- pattern to displaycanvas
- canvas to draw the pattern onpublic static void test(int n, DrawingCanvas canvas)
n
- Pattern that you are attempting to match - the same number you would pass to show()
canvas
- canvas which should be tested to see if its objects match the test set.