Graphic by Keith Ohlfs

CS111, Wellesley College, Fall 1997

Prelab #4
[CS111 Home Page] [Syllabus] [Students] [Lecture Notes] [Assignments] [Programs] [Documentation] [Software Installation] [FAQ] [CS Dept.] [CWIS]

CS111 Prelab #4: Methods

Due Date: Before lab, September 29 or 30.

In lecture you have seen how to create and use methods to draw a pattern of different sizes and positions without having to write the same lines of code repeatedly. In lab 4, you will be using methods to build a castle. In this prelab, you will create a method for one component of this castle: an arch.

1) First, download the folder, castle, from the download directory for cs111 on Nike. This folder contains 4 files:

2) View the applet using the appletViewer and opening the castle.html file. You should see something like the following:

3) Open the project window and double click on castle.java to look at the source code. You will see only one method, the paint method, that contains all the drawing statements. Your goal is to create a new method, called "drawArch", that takes seven parameters and draws an arch. The parameters are those listed at the top of paint and are as follows:

4) Modify the java source file as follows:

5) Once you have created the drawArch method, use it to create three arches side by side. (You will need three statements in your paint method, which call drawArch with different parameters). Use the following parameters:
 Arch
Color
Gate
Color
xy widthheight
Arch 1BlueRed5020010075
Arch 2GreenYellow1502007575
Arch 1RedBlue225200100150

When you view your applet, it should look like this:

Turning in Prelab 4

When you are finished. Save the four new castle files (castle.java, castle.proj, castle.class and castle.html) in a folder named "username_prelab4", where username is your username. Upload this folder into the lab4 drop folder on Nike.