teaching machines

CS 148 Lab 4 – Methods

September 25, 2019 by . Filed under cs1, cs148, fall 2019, labs.

Welcome to lab 4!

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 a sequence of code into a self-contained and reusable “recipe.” Methods have some very nice properties:

Checkpoint 1

Person A types.

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

Show your completed world 2 screen to your instructor or TA. If you are completing this outside of lab, take a screenshot.

Checkpoint 2

Person B types. Open your IntelliJ project and create a package named labs.lab04.

Java includes a pretty fun class named Robot that lets you programmatically hijack the mouse, grab screenshots, and issue keypresses. You can use Robot to interact with the computer as a human would, generating user input that affects any program.

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

Be sure to commit and push your work to GitLab after every coding session.