Hi There!

I'm Dan Schlegel, an Associate Professor in the Computer Science Department at SUNY Oswego

Programming Challenge 2: Microworld Problem Solving

Overview

Your task is to write computational solutions to three problems, two in the context of the Nonrepresentational Painting World (NPW), and one in the context of the Modular Melody World (MMW). This is meant as a followup to, or second part of, challenge 1. As before, relatively rigid constraints will be placed on you as you engage in these tasks, as is appropriate early in a CS1 course.

Why do it?

By composing Java solutions to the problems in the context of the featured microworlds you will:

  1. Gain considerable practice in creating and using objects.
  2. Continue to get acquainted with elements of graphics programming and sonic programming.
  3. Program, at least some of the time, in a manner that is consistent with the principle of stepwise refinement.
  4. Make explicit use of the problem solving strategy of problem decomposition.
  5. Write programs with invariance in mind.
  6. Learn just a bit about how to work from language specifications.
  7. Explore the notion creativity from constraint in the course of microworld problem solving.

The Entrance

Please be sure to complete Lab 2 and Programming Challenge 1 before starting this assignment.

Problem 1: Pump It Up!

In the context of the NPW, write a program called PumpItUp within the npw package to paint an image of the Pump It Up dance floor, much like the one depicted below.

Constraints:

  1. Use the technique of modifying an existing program that does something similar. Do so by:
    (a) Creating a new Java Main Class file for the program, naming it PumpItUp and placing it in the npw package.
    (b) Replacing the entire contents of the PumpItUp file with the entire contents of the BlueDot program.
    (c) Changing all occurrences of BlueDot to PumpItUp.
  2. Place the following code, without alteration, in the paintTheImage method.
    Then:
    (a) Use IntelliJ’s hints to add necessary import statements.
    (b) Use the light bulbs to create a stub for each of the unrefined program. (You should create 4 stubs.)
  3. One at a time, complete the definitions of the methods, proceeding as follows:
    (a) Run the program, and see that not much happens.
    (b) Refine the paintYellowSquare method, run the program, enjoy the yellow square.
    (c) Refine the paintRedSquares method, being sure to make it invariant with respect to both the location and heading of the painter, run the program, enjoy the yellow square and the red squares.
    (d) Refine the paintBlueSquares method, being sure to make it invariant with respect to both the location and heading of the painter, run the program, enjoy the yellow square and the red squares and the blue squares.
    (e) Refine the paintGraySquares method, being sure to make it invariant with respect to both the location and heading of the painter, run the program, and enjoy looking at the dance floor!

Problem 2: Dots

In the context of the NPW, write a program called Dots within the npw package to paint an image consisting exclusively of dots (painted circles) subject to the following constraints:

  1. it contains exactly 9 painted (filled in) circles
  2. it contains circles of exactly 4 different sizes
  3. it contains circles of exactly 4 different colors
  4. none of the circles touch
  5. the image is symmetric about the X-axis (i.e., the top and bottom of the image are a mirror image of each other)
  6. not all of the circles touch the X-axis

Problem 3: After Bach

Write a program called AfterJSB within the mmw package to play a melody composed exclusively of the figures available in MMW which were taken from JSB minutes, subject to the following additional constraints:

  1. The melody will consist of exactly 40 notes.
  2. The melody will make use of exactly 5 different modular melodic sequences (all drawn from the JSB modular melodic sequences). You may need to use one or more of these 5 more than once!
  3. The final note will be a long C note.

Due Date and Reminders

  1. Due date: Monday March 1, 2021
  2. Once you are ready, you must demo your programs for one of the TAs.
  3. You must post your work (source program and demo for each problem), to your Web Work Site. You will not receive any credit from the TAs until your work is posted on your Web Site!