CS111 Lab 3 -- Spring 2003

Total checkmarks:

Today's agenda:

 


Go to the download directory using cs111d on puma, and download the lab3_programs folder to your desktop.

JEM exercise

Draw JEM for the following example:

EXERCISE 1 -- Welcome to ChecksWorld!!!

What picture does ChecksSimple.java produce?

Run the project to see the answer.

Click here for the answer

 

Task 1 -- Drawing a pattern using Methods

Open the file ChecksMethod.java and the file CheckerBuggle.java.

You need to write a method of CheckerBuggle (in the file CheckerBuggle.java) which draws the same picture as the program in ChecksSimple.java does. Note that the class CheckerBuggle is an extension of the class Buggle, so you can use all methods of the class Buggle. Please follow these steps:

You may not use setPosition() in any exercises of this lab.

 

Task 2 -- Drawing a checkerboard using Methods

Modify the files Checksboard.java and CheckerBuggle.java to solve the problem. Move the file Checksboard.html to the top of Link Order to run the code.

In the file Checksboard.java create a new instance of the class CheckerBuggle.

Then add more methods to the class CheckerBuggle in CheckerBuggle.java and invoke some of these methods in Checksboard.java on the CheckerBuggle that you have created.

All the drawing and most of the moving must be done in methods of the class CheckerBuggle, not in run(). In this exercise and in the rest of the lab the method run() must be very short: just creating a new buggle and a few (between one and five) method invocations. If you write the program this way, it will be easier to reuse the methods from one exercise in another.

In the end of the program the buggle must be positioned as shown below. However, it may have any color (not white, as on the picture).


Task 3 -- Drawing a more complex checkerboard (using more Methods...). Write your code in the file BigChecksboard.java and add more methods to CheckerBuggle.java. Don't forget to move the file BigChecksboard.html to the top of Link Order.

 

Modify BigChecksboard.java to solve the problem:

 

Task 4 -- And even bigger and fancier checkerboard (using more Methods...). Write your code in the file BigChecksboard.java. You can modify BigChecksboard.java to solve the problem: