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: Fun Squares!

In the context of the NPW, write a program called FunSquares within the npw package to paint the colorful and fun image 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 FunSquares and placing it in the npw package.
    (b) Replacing the entire contents of the FunSquares file with the entire contents of the BlueDot program.
    (c) Changing all occurrences of BlueDot to FunSquares.
  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 paintYellowSquare 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.
    (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 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, red squares and blue squares.
    (e) Refine the paintGraySquares method, run the program, and enjoy looking at the fun squares!

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 11 painted (filled in) circles
  2. it contains circles of exactly 4 different sizes
  3. it contains circles of exactly 3 different colors
  4. none of the circles touch
  5. the image is symmetric about the Y-axis (i.e., the left and right sides of the image are a mirror image of each other)
  6. not all of the circles touch the Y-axis

Problem 3: Musical Scene

Write a program called MusicalScene within the mmw package to play a melody composed exclusively of the sequences available in MMW which represent locations and locomotion, subject to the following additional constraints:

  1. The melody will consist of between 43 and 45 notes.
  2. The melody will make use of exactly 5 different modular melodic sequences (all drawn from the location and locomotion modular melodic sequences). You may need to use one or more of these 5 more than once!
  3. You must ask the composer to raise its note at least once.
  4. The final note will be a C note.

Due Date and Reminders

  1. Due date: Tuesday September 27, 2022
  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!