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: Kanizsa Square

In the context of the NPW, write a program called KanizsaSquare within the npw package to paint an image of a (more colorful than usual) Kanizsa Square, 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 KanizsaSquare and placing it in the npw package.
    (b) Replacing the entire contents of the KanizsaSquare file with the entire contents of the BlueDot program.
    (c) Changing all occurrences of BlueDot to KanizsaSquare.
  2. Place the following code, without alteration, in the paintTheImage method.
    Then:
    (a) Use the features of IntelliJ to add the necessary import statements.
    (b) Use the light bulbs to create a stub for each of the unrefined methods. (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 paintBlueCircle method, being sure to make it invariant with respect to both the location and heading of the painter, run the program, enjoy the blue circle.
    (c) Refine the paintRedCircle method, being sure to make it invariant with respect to both the location and heading of the painter, run the program, enjoy the blue circle and the red circle.
    (d) Refine the paintGreenCircles method, being sure to make it invariant with respect to both the location and heading of the painter, run the program, enjoy the blue circle, red circle, and green circles.
    (e) Refine the paintWhiteSquare method, run the program, and enjoy looking at the Kanizsa square!

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 Y-axis
  6. not all of the circles touch the Y-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: Friday September 18, 2020
  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!