![]() |
Problem Set 1
|
This problem set will get you acquainted with your instructors, with the mechanics of CS111 programming, and with basic Java coding.
On each of the first three assignments, you must go to one of the instructors' office hours or arrange a meeting and secure a sticker. You'll put this sticker on your cover sheet (see below). After three assignments, each of us will have seen all of you!
Download the ps01_programs
folder from the cs111
server by using the cs111d
account and the
password provided in lecture. Rename this folder
Wendy_ps01
, except, of course, you should replace
Wendy
with some word that uniquely identifies you.
Create and code a Writing.java
file and make your
modifications to the given Rings.java
file 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.
Create a new file called Writing.java
and save your modified
Rings.java
files. Print out a hardcopy of your final versions of the
Rings.java and Writing.java
files.
Upload the ps1
folder containing your modified files
into the ps1 drop
folder on the cs
server.
Turn in only one package of materials. Staple your files together with a cover page, and submit your hardcopy package 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:
cs
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.We want to ensure that all of us meet all of you, and that everyone is comfortable coming to see us. So, for each of the first three problem sets, you will be required to drop in on someone's office hours (or schedule an appointment if that isn't possible). Each week you must meet a different one of us, and it doesn't matter what order you meet us in.
Go to one of some instructor's office hours (your choices are: Sohie, Mark, and Lyn). If you cannot make office hours, you must schedule an appointment. Go to the office and secure a sticker from the instructor you meet. Place that sticker on the problem set cover page.
You cannot get credit for this assignment without a sticker, and we will NOT give you a sticker in class or lab.
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 "PS1!" in multiple colors:
.
Your assignment:
Create a new file called Writing.java
in your ps1
folder.
Set up the grid so that it is 16x16, and create a single Buggle to write PS1!.
In your run()
method, add code to write
"PS1!"
as shown above.
You must conform to the following rules:
setPosition()
or
setHeading()
methods.brushUp()
and
brushDown()
where appropriate.setColor()
to change colors).Your buggle
must end up in the position shown above,
facing the correct direction (EAST
).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:
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.