Graphic by Keith Ohlfs
CS111, Wellesley College, Fall 2001

Problem Set 1

Due Tuesday, September 18 by 11 p.m.

[CS111 Home Page] [Syllabus] [Assignments] [Documentation] [FAQ] [CS Dept.] [CWIS]

Reading

About this Problem Set

Download the ps1_programs folder from the download directory on nike (follow the Programs link in the menu at the top of this page). Rename this folder Wendy's ps1, except, of course, you should replace Wendy with some word that uniquely identifies you. (If you see somebody else's folder on the Desktop, drag it to the trash and empty the trash. It would be a violation of the Honor Code to open the folder.) Make your modifications to the Writing.java and Rings.java files to solve the 2 problems defined in the two tasks below. The problems are intended to give you practice writing simple Java code. Both problems use the BuggleWorld microworld you have been studying in lecture.

How to turn in this Problem Set

Save the modified Writing.java and Rings.java files in your ps1 folder to be turned into your drop folder. Be sure that each .java file has a comment at the very beginning that includes your name, your user name on nike, and the names of people with whom you collaborated for this problem set.

Put your ps1 folder containing the completed source code into your ps1 drop folder on the cs111 server.

IMPORTANT NOTES:

  1. Pay careful attention to upper and lower case letters in the filenames.
  2. 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.
  3. Once you are done with your work, and you have made TWO COPIES of your ps1 folder, drag it to the trash and empty the trash. This step is not optional! If we sit down at a Macintosh and find that you have left your folder on the Desktop or in the trash,we will deduct 20% from the homework that you left lying around.

Task 1: Buggle Name Writing

In lecture and lab, we have learned that in BuggleWorld, buggles can be used to make patterns or write letters within a grid. Below, a single buggle has written the name "JAVA" in multiple colors:

.

Your assignment:

In your ps1 folder there is a file, Writing.java, which contains a Java program to create a single buggle ellie. Add code to the run method to write the name "JAVA" as shown above.

You must conform to the following rules:

  1. You may not invoke the "setPosition" or "setHeading" methods.
  2. You should use the methods "brushUp" and "brushDown" where appropriate.
  3. Each letter except "V" should fit in a 4x5 grid, and should be separated from the next letter by one blank space.
  4. The letter "V should occupy a 3x5 grid as shown.
  5. Ellie must draw the letters in the appropriate colors (use "setColor" to change colors).
  6. Ellie must end up in the position shown above, facing the correct direction (EAST).

Task 2: The Buggle Olympic Symbol

In BuggleWorld, the buggles regularly hold competitions in which they run the hurdles or traverse obstacle courses. Because they enjoy these competitions so much, they have decided to hold the first Buggle Olympics. To prepare for the big event, they have decided they need an appropriate symbol. They like the idea of interlocking rings, but due to the constraints of BuggleWorld, their rings have to be squares instead of circles. They have designed the following logo for their olympics:

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, bertie the blue ring, billy the cyan ring and benny the magenta 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. Fill in the java code to move each buggle around a 7 x 7 square, so that the rings overlap each other as shown.

You must conform to the following rules:

  1. You may not invoke setColor, brushUp, brushDown or setPosition methods beyond what is given you in the initial set-up file (i.e. setColor and setPosition are used only once for each buggle). The buggles use only the forward(n) and left() methods.
  2. Each buggle should traverse their square ring only once. They should not revisit any square they have already visited, except for the starting square, which they end on.
  3. Pay careful attention to the color of the squares where the rings intersect. You must get the buggle of the appropriate color to cross these intersections after the other buggle. This means that a buggle may have to stop in the middle of its drawing and wait for another buggle to complete a portion of its ring.