Hi There!

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

Programming Challenge 4: Nonrepresentational Artistic Expressions

Overview

Your task is to write several separate Java programs for this assignment, all but one in the context of the Nonrepresentational Painting World (NPW). These programs, with the one exception, will make use of both the painter functionality and the shapes functionality of the world. You will be asked to place each of these programs, including the one exception, in the npw package of your CS1 project.

Why do it?

By composing Java solutions to these non-representational artistic expression problems you will:

  1. Gain considerable practice in creating and using objects.
  2. Gain considerable practice in reading and understanding programs written by others.
  3. Gain considerable practice in program modification.
  4. Practice using selection and repetition constructs.
  5. Further explore the notion of creativity from constraint in the course of microworld problem solving.

The Entrance

You should review the Nonrepresentational Painting World functionality, and the mechanisms for selection and repetition previously presented in lecture and in lab. You might also like to adopt a frame of mind in which laying down shapes in the plane resonates with nonrepresentational art. Perhaps you would like to Google Klee, Stella, Hirst, and a number of other modern artists, in order to explore some of their images and ideas.

Problem 1: The Cave

There is a style of top-down video game where you move through progressively narrowing, winding caves. This style of game first appeared as a text-based game. In this problem you’re going to generate a piece of a map for one of these games. If you don’t like that kind of thing, you can think of this as just generating a nice little text-based image.

Write a program called CaveMap in your npw package that will (1) accept, from the standard input stream, data corresponding to the width of the map, and the width of the cave, and (2) print, to the standard output stream, the map made of stars to represent a wall, and white space to represent the cave. Your program should be consistent with the following set of three demos:

Moreover, your program should be consistent with the following Java program text. What we did was to write the program, and then delete the instructions within the main method, and the entire drawOneRow method. Your job is to add the instructions back. Or at least, instructions which will do the job. Other than adding instructions pertaining to these two methods, all of the executable code should remain exactly as in the accompanying program text. You should be able to use your program to generate the game maps that appear in my demo, and many others, as well.

Problem 2: Entropy

Write a program called Entropy in your npw package to paint a series of vertical columns, each with several diamonds in them, with the diamonds exhibiting more randomness in terms of rotation, size, and location as they move to the right. The width and height of the canvas, as well as the scale of the diamonds, should be read from dialog boxes. Actually, we have written this one for you. What we would like for you to do is enter it carefully (don’t copy/paste!), run it several times, and study it! It’s important that you understand how it works for later parts of this assignment.

Problem 3: Entropy in Color

Write a variant of the Entropy program which uses color, set by column. Your program might use randomized colors in some way, or it might use some range of colors to achieve some effect you like. The only constraint is that you must make some use of the chaosFactor variable in choosing your color. You should do this task as follows:

  1. Copy the code from the Entropy class into a new class, called EntropyInColor.
  2. Edit the EntropyInColor class, replacing all occurrences of “Entropy” with “EntropyInColor“.
  3. Modify the chooseColor method to pick a color based at least in part on the chaosFactor. Be sure to modify the call to this method appropriately. Important: Do not remove any instructions. Do not modify any other instructions. Just modify the call to the chooseColor method, and add instructions in that method as specified.

Of course you will want to run your program a number of times to be sure it’s doing what it’s supposed to.

Problem 4: Hirst Lattice

Write a variant of your EntropyInColor class in your npw package which paints images like the one shown. Call this program HirstLattice. Moreover, do this task by:

  1. Copying and pasting the code from the EntropyInColor file to a newly established HirstLattice file.
  2. Edit the HirstLattice file by replacing all occurrences of “EntropyInColor” by “HirstLattice” and also modifying the leading comment.
  3. Replace the chooseColor method with the randomColor method we’ve seen in lab, and modify your program so that it chooses a random color for each diamond it paints. Moreover, remove the code which causes random variation in diamond size, rotation, and position.

Run your program a number of times to see that it is doing what it is supposed to do.

Problem 5: Hirst Dots

This one requires a couple clever thoughts! Be sure you have read and understand all of the code in the previous two problems.

Write a variant of your HirstLattice class in your npw package which paints images like the one shown. Call this program HirstDots. Moreover, do this task by:

  1. Copying and pasting the code from the HirstLattice file to a newly established HirstDots file.
  2. Edit the HirstDots file by replacing all occurrences of “HirstLattice” by “HirstDots” and also modifying the leading comment.
  3. Do what needs to be done to your program to paint circles instead of diamonds. Moreover, paint the circles at half the size of the diamonds we painted before.

Run your program a number of times to see that it is doing what it is supposed to do.

Problem 6: Deterministic Invention

Write a program called Invention1 in your npw package which paints an image subject to the following constraints. Do not just modify the above programs in 2-5 – make your own thing! Your invention should be significantly different from other students’ inventions!

  1. It uses at least one while statement in a nontrivial way.
  2. It uses at least one if statement in a nontrivial way.
  3. It features both circles and squares, all created from just one SCircle and just one SSquare. No SRectangles.
  4. It creates the exact same image every time it is run.
  5. There is some chance that the casual observer might find the image interesting!

Run it (at least) twice to make sure the output is the same each time you run the program.

Problem 7: Nondeterministic Invention

Write a program called Invention2 in your npw package which paints an image subject to the following constraints. Do not just modify the above programs in 2-5 – make your own thing! Your invention should be significantly different from other students’ inventions!

  1. It uses at least one while statement in a nontrivial way.
  2. It uses at least one if statement in a nontrivial way.
  3. It features solely rectangles, all generated from a single SRectangle.
  4. The program takes no input from the user of the program.
  5. It creates a different image each time the program is executed, different with respect to number or size or color or whatever of the featured object.
  6. There is some chance that the casual observer might find the image interesting!

Run it twice to make sure the output is not the same each time you run the program.

Problem 8: Pinwheel

Write a program called Pinwheel in your npw package which paints images like the ones just presented. The constraints are these:

  1. The number of squares will be read from a dialog box.
  2. Two randomly chosen colors will be used for the image that is painted when the program is run.
  3. The canvas will be of size 600 by 600 and the square will be 400 by 400.

Run the program several times, doing your best to enjoy looking at the output.

The Exit

  1. Due date: Tuesday October 31, 2023.
  2. Once you are ready, you must demo your programs for one of the TAs.
  3. You must post your work, a source program and an appropriate demo for each problem (Standard Output Stream for the first problem, images for the remainder of the problems), to your Web Work Site before you demo in order to receive credit.