Lab: Writing the Java Program
In this lab, you are to take this almost completed Java program to draw Pascal's triangle.
Here is a running version that
draws one circle. Note that the parts that change colors
and the number of rows R and the modulus N are already written. Your part is to fill
in the drawing using this
partially written program.
On your PC, the program JavaEdit should be running. It has two files loaded, Pascal.java
and Pascal.html, as inidicated in the tabs at the bottom of the window.
- Edit the file Pascal.java. Select that file tab and look at the program. Near the bottom
of the file is a method called paint that does
the drawing. Parts of this method have been filled in for you. You are to add the parts
that define the array values and that defines x and y locations to draw the circles. Note
that within the symbols /* and */ are "comments" that tell you what to do. Anything within
these symbols are ignored as a program.
- When you think your program is done, you will need to compile it. Go to the menu
item called run and click on Compile. If there are errors in your program (and there are
bound to be at first), correct them with the help of the instructor or TA's. Then compile
again until it says that it compiled o.k.
- Now select the Pascal.html tab. To view your applet, go to the menu item called run
and click on Load in Browser. A window should come up to view your applet. How
many rows can you view? Which colors do you like? Do the different mod numbers
all work?
Congratulations! You have just finished your part of a Java program!