CS111 Spring 2008

Problem Set 3

Due Tuesday 19 February 2008

About this Problem Set

This problem set is will help extend your knowledge of Java methods and parameters. There's also an ungraded challenge problem for anyone interested in testing the limits of their programming savvy. There is a contest associated with the challenge problem (please see below) with PRIZES (hint: think Bagels!).

To get the code for this assignment, connect to the cs111 download directory via Fetch and download the folder ps03_programs.

How to turn in this Problem Set

Save the modified Writing3.java and RugWorld.java files in the ps03_programs folder. Submit the entire ps03_programs folder to your drop folder on the cs111 server. Turn in a hardcopy of your modified Writing3.java and RugWorld.java files. If you chose to work on the ungraded challenge problem, you should also turn in the FontBuggle.java and HuggleWorld.java files.

When submitting your hardcopies, turn in only one package of materials. Please staple your files together with a cover page, and submit your hardcopy at the start of class on the due date. Don't forget to put one of the instructors' stickers on the cover page!

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. 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. Please make sure to keep a copy of your work, either on your own computer (or some other storage medium), or in your private directory (or, to play it safe, both).

Task 0: Meet the Instructors

In the previous two weeks, you met one of the instructors (Stella or Mark) during her/his office hours. (Some of you may have seen us both already — great job!) This week, you must meet the other one of us! Go to the other instructor's office hours and secure a sticker (you cannot see the same person you saw last time!). If you cannot make office hours, you must schedule an appointment. Place the sticker on the problem set cover page. Now you have met both of us!

You will receive a 0 on an assignment for each missing sticker, and we will NOT give you a sticker in class or lab. This is the last week to get a sticker.


Task 1: Buggle Word Writing using Methods (the last chapter)

This task uses methods to expand the capabilities of the buggle word writing program from problem sets 1 and 2. In this problem, a buggle can write a more colorful "JAVA" around the perimeter of the grid, as shown below:

Your assignment:

Using methods, create the above grid. Create a new Java file Writing3.java, which will be similar to the Writing2.java file from the previous problem set. You can, and as a matter of fact you are encouraged to, re-use code from your previous assignment. In particular, the methods you defined in Problem Set 2 to write the individual letters (J, A, and V) do not need to change at all for this task. You only need to change the writeName() method, to make it more flexible, so it now produces multi-colored JAVA words, instead of uni-colored ones! Of course, the way the writeName() method is called/invoked, in the run() method, should change as well, to reflect the changes in its definition.

All the rules from Task 2, in Problem Set 2 hold here as well.


Task 2: The Buggle Bagel Ruggle Company


Important note: Before you begin working the third task, make sure to save and close all Java files from the previous task.
The buggles from Problem Set 1 (blithe, cy, maggie, rex and yelena) had the foresight to copyright their Buggle Olympic Symbol. As a result, they made a killing on the use of the logo for Buggle Olympics memorabilia and merchandise. So, they decided to invest in a rug-making enterprise: The Buggle Bagel Ruggle Company, which designs and weaves rugs made by dropping bagels in interesting ways on a BuggleWorld grid. Here is an example of a rug they created:

The buggles are great designers, but, unfortunately, they don't know much about manufacturing. It takes so long to hand-drop the bagels individually that it's impossible to make any money. Luckily for them, there is a way to automate the production of the rugs. As it turns out, the design shown above can be produced using just 4 different 3x3 grids of bagel/color patterns:

pattern1(Color.black, Color.yellow)

pattern2(Color.black, Color.yellow)

pattern3(Color.black, Color.yellow)

pattern4(Color.black, Color.yellow)

Each of these 4 patterns is parameterized by two colors that allow different colors to be used in different situations.

The rug itself is created by placing these patterns side by side to tile the entire rug. The rug, divided into 3x3 grids (outlined in black lines), is shown below:

Your task is to write code that draws the rug pattern shown above. This rug pattern is composed of many repeated subpatterns. This means that there are many opportunities for using methods to simplify the drawing of the rug pattern. Your goal is to describe as many subpatterns as you can using methods to avoid writing statements for the same subpattern twice.

The code for this problem is contained in the RugWorld folder. You will be editing the file RugWorld.java. This file contains the complete definition of a BuggleWorld subclass named RugWorld (which you should not change) and the skeleton of a Buggle subclass named RugBuggle that you must flesh out. The run() method of the RugWorld class creates a single RugBuggle named weaver that draws the entire rug via the makeRug() method in the RugBuggle class:


public void run() 
{
     RugBuggle weaver = new RugBuggle();
     weaver.brushUp();
     weaver.makeRug();
}

Note that weaver's brush is up when it starts drawing the rug.

You must observe the following guidelines to complete this task:

Helpful Hints:


Non-Graded, Non-Credit Challenge Problem: HuggleWorld

Up for a challenge? Here's a golden opportunity to put your buggle skills to the test. Design greetings cards and win a bag of baggles. Click here for more details.