CS 104 Lab # 1
An Introduction to Java Programming

Objective:   To demonstrate the use of Java and ACM Java Library
Hypothesis:   None for lab1
Solution:   A complete program with proper format and comments.



Writing a Java Program

First follow the instructions here to install the necessary software and configure it. Ask the instructor or the lab assistants if there are questions.

After the initial configuration, download this file and unzip it into a directory for CS104. Double click on package.bluej file to open it in BlueJ. Then try to compile it. After it is successfully compiled, right click on RobotAndPizza and select "Run ACM Program" to run the program. This will be the basis of your program. You will modify and extend this program to accomplish the lab assignment.

For this lab you'll construct a Java program to draw the face of a robot, as shown below.

When the program starts, a robot face and a slice of pizza are drawn. When the mouse enters the program window, the robot's eyes turn yellow. If the mouse is pressed inside the pizza, a message "Gimme the pizza!" appears inside the robot's mouse; and if the mouse is pressed outside the pizza, the robot's eyes and its antennas turn red. When the mouse is released, the robot face returns to its original appearance.

 

Grading Guidelines

This lab is worth 20 points, which are distributed as follows:

Value

Feature
6 pts. Drawing the objects correctly when the program starts (it does not have to be exactly the same as the sample program, but it should look similar and be aesthetic)
6 pts. React to mouse events in the same way as the sample program
4 pts. Meaningful names used in declarations
4 pts. Good and consistent formatting of code
1 bonus pt. Any other interesting non-trivial feature (awarded at Instructor's discretion)