Hi There!

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

Assignment 1: Microworld Problem Solving

Overview

Your task is to write computational solutions to six problems, three in the context of the Nonrepresentational Painting World (NPW), and three in the context of the Modular Melody World (MMW). Relatively rigid constraints will be placed on you as you engage in these tasks, as is appropriate for a first programming challenge 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. 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 before starting this assignment. Beyond that, you should study the programs featured in Lab 2. You should also take a some time to get at least casually familiar with the NPW functionality (Appendix 1 of the CS1 Lab Manual) and the MMW functionality (Appendix 2 of the CS1 Lab Manual).

Problem 1: The Red Cross

In the context of the NPW, write a program called RedCross within the npw package to paint a red cross (plus symbol) in a 600 by 600 canvas whose legs are 500 by 100. Featured constraint: Create and use one and only one rectangle.

Other constraints:

  1. Use the technique of modifying an existing program that does something similar. Do so by:
    (a) Creating a new Java Class file for the program, naming it RedCross and placing it in the npw package.
    (b) Replacing the entire contents of the RedCross file with the entire contents of the BlueDot program.
    (c) Changing all occurrences of BlueDot to RedCross.
  2. Place all of the code for creating and using the sole rectangle object in the paintTheImage method.

Problem 2: 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 the light bulbs to add the 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 3: 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 8 painted (filled in) circles
  2. it contains circles of exactly 3 different sizes
  3. it contains circles of exactly 3 different colors
  4. none of the circles touch
  5. the image is symmetric about the X-axis
  6. not all of the circles touch the X-axis

Problem 4: Two Figure Minuet Thing

In the context of the MMW, write a program called TwoFigureMinuetThing within the mmw package to play the exact same sequence of ten notes that is played by the following program, subject to the constraint that you may not use any SComposer objects. Thus, you will have to write the program using only an SNote object.

Problem 5: Minuet Figure Viewer

In the context of the MMW, write a program called MinuetFigureListener within the mmw package to simply play each of the Bach (JSB) minuet figures that are available in the MMW, in such a way that they are textually displayed. Do so by using Task 4 of Lab 2 as a model. That is, work by explicit analogy with the program featured in that task.

Problem 6: 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).
  3. The final note will be a long C note.

Due Date and Reminders

  1. Due date: Wednesday February 20, 2019
  2. Once you are ready, you must demo your programs for one of the TAs.
  3. Eventually, you will post relevant artifacts to your Web work site.