teaching machines

CS 145: Lab 3 – Methods

September 23, 2017 by . Filed under cs1, cs145, fall 2017, labs.

Welcome to lab 3!

If you have checkpoints from the last lab to show your instructor or TA, do so immediately. No credit will be given if you have not already completed the work, nor will credit be given after the first 10 minutes of this lab.

Work with a partner that you have not worked with before.

Our goal today is to learn more about methods, which let us extract reusable sequences of code into a separate block of code. Methods have some very nice properties:

Checkpoint 1

Person A types.

Play Lightbot. Complete the first two worlds: Basics and Procedures.

Checkpoint 2

Person B types. Open your Eclipse workspace and create a package named lab03.

The Java library includes a pretty fun class named Robot. With Robot, you can hijack the mouse pointer, grab screenshots, and programmatically issue keypresses. Essentially you can make your program act as a fake user, generating user input—even in other programs.

In this checkpoint, you’ll use Robot to control a drawing program. Follow these steps to get it up and running.