Skip to main content

Interactivity & Rivalry

Summary of Deliverables

By the end of HW01, here’s what you’ll need to submit to Gradescope:

1. Getting Started


The general goal of this assignment is to write three Java programs which make use of loops and conditionals. The specific goals are to:

All the necessary files for this assignment can be found on Codio, but if you’d like to download them separately they can be found here.

As always, you can reference the PennDraw resource here and the CIS 1100 Javadocs here for reference to the functions you may need to use.


This assignment is split in three parts. In the first part, you will write a program that responds to user key input; in the second, you will write a program that responds to the user’s clicks on a canvas; in the third, you will write a simple animation.

2. LetterViewer

Write a program that displays the most recently pressed key in the center of the screen. You can find the starter file in your Codio, called, or you can download it here.

The canvas should be blank until the first key is pressed. Then, the most recent character pressed should remain on the screen until the next character is pressed.

LetterViewer Demo

Some notes:

3. LineDrawingTool

Write a program that connects lines between the last place the mouse was clicked and the most recent place the mouse was clicked. You can find the started file in your Codio, called, or you can download it here.

The canvas will be blank until the first mouse click. The first line should be drawn from the center of the screen to the most recent mouse click. If the mouse is clicked in the top half of the screen, draw the line in red. If the mouse is clicked in the bottom half of the screen, draw the line in black.

LetterViewer Demo

Some notes:

4. Rivalry

Help Resources

Program Overview

You will write a program that visualizes a race between two contestants. Do not set up the program yet. Read through all of this portion of the assignment first so you have an understanding of the big picture before you start setting up. Once you read the following description, you can use the skeleton code provided below to start coding the program.

As you are well aware, Princeton is one of Penn’s main rivals. So for the example race, we used an image of the Penn pennant and an image of the Princeton pennant as the two racing rivals. In your program, you will choose two images that represent your own favorite pair of rivals. For example, you may want to use images of Nicki Minaj and Cardi B or Apple Music and Spotify. Once you choose your images, download them as png files and upload them to Codio (File -> Upload).

Here is an example of what the race will look like. Since the movement of the pennants is randomly controlled, the final state of the pennants in the image below is just an example; the result will be different each time the program is run.


Program Setup

On Codio, open the Rivalry assignment. You should see the file you will write for this portion of the assignment,, as well as the readme for the assignment, which you will complete at the end. You can also download the file here if you need it.

The skeleton code for has the word TODO in places where we want you to fill things in. Once you complete the TODOs, you should delete these comments and add your own comments to describe the functionality of your code. You will see the use of enableAnimation(), disableAnimation(), and advance() in the skeleton code. Read the animation section of the PennDraw wiki for an explanation of these functions to understand why we use them.

Use the specifications from below, along with the skeleton code, to create the race between your rivals. Always write code in small steps. Compile and test after each step. Do not move on to another task in the program until you are sure your current code is working.

Rivalry Specifications

These specifications are very thorough. Please read them carefully. As stated in the Goals of this assignment, part of the purpose of this assignment is to get you used to following detailed instructions to the letter. You will be graded on strict adherence to these requirements.

Your program must follow the specifications below:


readme_rivalry.txt is included in Codio, or you can download it here. Open it in Codio, and answer the questions.

Extra Credit?

We offer some extra credit in CIS 110 to give you the opportunity to show that you really know your stuff! The purpose of extra credit is not to dramatically alter your score; in fact, although this assignment’s Extra Credit is a very challenging extension of the base assignment, you can only earn at most 1 point. Details about Extra Credit components are included at the end of the write-up.


Submit your homework under HW01 on Gradescope. You need to upload,,, readme_rivalry.txt, and any and all images you used in Rivalry.

All program file names should match the required names exactly, including capitalization. Make sure you submit the .java files, NOT the .class files.

Again, you must submit all image files you used in your programs exactly with the exact file names as they appear saved in your HW01 folder.

Extra Credit Opportunities

You can earn a maximum of one point in Extra Credit on this assignment, regardless of how many challenge problems you attempt. You only need to complete one to receive the point.

Wandering Eye

Draw one or more eyes with pupils that follow the cursor. If you can, constrain each pupil to stay within its eyeball!


Shy Follower

Objects rarely move at a constant speed in the real world. Create a sketch in which an ellipse follows the position of the cursor but decellerates on approach. This process is called easing.


Improving Rivalry

Implement by custom drawing your rivals with PennDraw functions instead of using picture files! Your rival drawings must make use of at least five (not necessarily different) PennDraw function calls to be counted for credit.