![]() Graphic by Keith Ohlfs |
|
Click here for an image only version.
There are 3 pieces to this problem set: the prelaboratory assignment, the laboratory assignment and the homework assignment. You are required to do all three parts. We recommend that you do the prelaboratory assignment before your lab section, the laboratory assignment during your lab section and the homework assignment after completing the prelab and lab assignments.
Prelab Assignment: Save your html file that contains the applet tags in a text file named coalesce.html and put it into your folder in the ps2 drop folder on the cs111 server. Turn in a hard copy of this html file.
Note:Although we expect you to do the prelab before coming to lab, you do not need to hand this in until the assignment due date (September 25).
Laboratory Assignment: Turn in a hardcopy of the BuggleCS.java file.
Important Note: Pay careful attention to upper and lower case letters in the filenames.
Homework Assignment:
Turn in a hardcopy of the modified Writing.java and Rings.java files.
Put the Buggles folder containing the completed laboratory and homework source code into your ps2 drop folder on the cs111 server.
When submitting your hardcopies, we ask that you turn in only one package of materials. Please staple your files together with a cover page, and submit your hardcopy package by placing it in the box outside of Stanzi's office (E106, directly across from E101).
IMPORTANT NOTE - Once you have used Fetch to upload a file to the cs111 server, you should be sure to doublecheck that the file was actually uploaded. You can do this in Fetch by verifying that the file is now listed in your directory. Not only should you check that the file is listed, but you should check that it does not have a size of 0K. If the file isn't listed or if the size for the document is 0K, this means that there was an error in transferring it via Fetch and you must re-upload the document. When transferring a folder, you should check that its contents have been uploaded correctly. That is, you should be sure to check that every single file that you wish to submit has been uploaded correctly. Often times, although not always, you will see a message "Connection Failed" when there is an error in transferring your files.
ANOTHER IMPORTANT NOTE - It is your responsibility to keep a personal back-up of every file that you submit electronically until you have received a grade for the assignment.
From the documentation page, click on the "Instant Java" link to go to the instant Java Applet Repository. Click on "Assorted Applets". From there, click on "CoalesceContinuous". (Alternatively, click here to go there directly ). In the menu bar of Netscape, you can note that the location of the current page is:
"http://www.vivids.com/ij2/assorted/CoalesceContinuous.html".
You will see some applet code on the Instant Java page; Do not use this code! Instead, from the Netscape File Menu, choose "View Document Source" and find the applet tags that this web page actually uses.
Select everything from <applet... to </applet> on the HTML source page and copy it. Save it into a text file on your local Mac (you can use the Symantec Project Manager editor to do this, or a text editor such as SimpleText. Do not use a word processor, such as Word). Insert enough HTML tags to create a minimal web page that you can view with netscape:
<HTML>
<HEAD>
</HEAD>
<BODY>
The Applet goes here
</BODY>
</HTML>
Save this file as a text file, named coalesce.html
codebase = ../AllClasses
This means that the class files resides in a directory named "AllClasses" which resides in the directory that is one above (In the directory hierarchy) the directory that the CoalesceContinuous.html file resides in. Noting the address of the CoalesceContinuous.html file, you can find the appropriate directory as follows:
In lecture you were introduced to Buggleworld. In this world you can create "Buggles" that can move in different directions and draw onto their grid world. Today in lab you will learn how to use the Symantec project manager to modify an applet that uses Buggles. We will first download some pre-written applets, BuggleCS, Writing and Rings, from the download subdirectory of cs111 on the cs111 server.
1) First, download the folder, Buggles, from the download directory for cs111. This folder contains four java source files (BuggleWorld.java, BuggleCS.java, Writing.java and Rings.java), three html files (BuggleCS.html, Writing.html and Rings.html), many class files and one project file. Make sure all the icons are displaying the proper images (e.g. a coffee cup on the class files). If they are not, download the fetch preferences again and try again.
2) To run the BuggleCS applet, take the following steps.
When programming in Java, you will often make mistakes typing or in designing your program code. These mistakes will lead to two types of errors: Compiler errors, which cause error messages during the compilation of your program, and run-time errors, which allow the program to compile, but cause it to do the wrong thing. These errors are often called "bugs". Knowing how to find and correct bugs in your code (known as debugging) is an extremely important skill for a programmer. We will examine the following common types of errors (one at a time).
Together we will change the code, so that becky buggle draws the letter "C", as follows:
Now that you've had a chance to modify and debug some code, it's time to try it on your own. Modify BuggleCS.java file so that becky draws the "C" as before, and bobby draws an "S" as follows:
Because becky gets tired if she has to make too many large jumps around BuggleWorld, she has requested that you show her how to write "CS" without invoking the "setPosition" method. She is perfectly happy to lift her brush up (by invoking the method "brushUp") and put her brush down (by invoking the method "brushDown") so that she will only leave a trail when required. She also likes the idea of writing with multiple colors, so she would like to write the C in red and the S in yellow.
Part A
Modify the Writing.java code so that becky draws the letters "C S". The resulting letters should look as follows:
.
You must conform to the following rules:
Part B
Becky is so excited that she runs around the edge of the grid writing CS111 over and over. At the end, she is tired but happy.
The same rules apply.
Five buggles--becky, bobby, bertie, billy and benny--have agreed to help out in drawing the rings. becky wants to draw the red ring, bobby the yellow ring and bertie the blue ring. Each would prefer to draw only in one color and not change colors in the middle of their ring. Furthermore, they would prefer not to have to put their brushes up and down while drawing their rings. They have asked you to help them choreograph their movements so that the rings get drawn the correct way, with each ring overlapping the others as shown above.
Your assignment:
The file "Rings.java" contains the initial set-up for drawing the olympic rings. becky, bobby, bertie, billy and benny are all in the appropriate starting position and are the appropriate color.
Now, you must fill in the java code to move each buggle around a 5 x 5 square, so that the rings overlap each other as shown. You must conform to the following rules: