Skip to main content

Rivalry and Click Art


1. Getting Started

Goals

The general goal of the Canvas Creations assignment is to write two Java programs which make use of loops, and conditionals. The specific goals are to:

Background

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

Help Resources


2. Rivalry

Program Overview

You will write a program Rivalry.java 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.

img


Program Setup

On Codio, open the Rivalry and ClickArt assignment. You should see the two files you will write for this assignment, Rivalry.java and ClickArt.java, as well as the readme for the assignment, which you will complete at the end.

The skeleton code for Rivalry.java 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

Your program must follow the specifications below:


3. ClickArt

Write a program ClickArt.java, with the following specifications. Read all of this section beginning the coding process.


ClickArt Specifications

Your program must follow the specifications below:


ClickArt Setup

To help you get started, ClickArt.java’s skeleton code is included in Codio. Again, the TODO annotations are where we expect you to fill in your code. Once you complete the TODOs, delete the TODO comments. The non-commented code can be used as is.


Readme

readme_rivalry.txt is included in Codio. Open it in Codio, and answer the questions.


Extra Credit

Implement Rivalry.java 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.


Submission

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

All program file names should match the required names exactly, including capitalization. Make sure you submit the .java files, NOT the .class files, and, if they’re being generated, NOT the .java~ files. If you don’t see .java~ files being in your directory, don’t worry about this.

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.