CS 102 Lab # 1
An Introduction to Java Programming

Objective: To demonstrate the use of Dr. Java

Writing a Java Program

In order to create the folders and programs you need for the lab, download this file by right-clicking on the link; click "Save Link As " in the dialogue window. Save the file in your home folder.

We will need to use terminals throughout the labs. To add the terminal icon to the desktop, first get to the application by clicking "Applications->Accessories". Right click on the "Terminal" icon and select "Add this launcher to desktop". Now you have the Terminal icon on the desktop. You can just double click it to open a terminal window.

 Now open a terminal window. In the new window that opens, type source ./init and press Enter. Now log out and log back in again to make sure your environment is properly set up. Start the browser again using the globe icon to view the lab online.

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

You will use a program named Dr. Java which provides everything you need to type in and run Java programs. Here is how to use Dr. Java: Explain

You will accomplish the assignment by adding code to an existing file that we have provided for you. Here is what you should do: Explain

Finally, you need to make your program responsive to mouse events. Here is what you need to do: Explain

You may find the objectdraw cheat sheet helpful.

Grading Guidelines

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

Value

Feature
6 pts. Drawing the face 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 symmetric)
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