Hi There!

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

Assignment 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 program modification.
  3. Practice using selection and repetition constructs.
  4. 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: Text Rectangles

Write a program called TextRectangles in your npw package that will (1) accept, from the standard input stream, data corresponding to the number of rows and number of columns in a rectangle made up of stars, and (2) print, to the standard output stream, the rectangle of stars. 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 I 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 rectangles that appear in my demo, and many others, as well.

Problem 2: Abstract Gradient

Write a program called AbstractGradient in your npw package to paint a series of vertical columns, each with several dots in them, with the dots growing closer together as they near the bottom of the canvas. The width and height of the canvas, as well as the space between the dots horizontally, should be read from dialog boxes. Actually, I have written this one for you. What I 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: Random Color Abstract Gradient

Write a variant of the AbstractGradient program which uses randomized colors. Your program might randomize to any colors or use some range of colors which you define in order to achieve some effect you like. You should do this task as follows:

  1. Copy the code from the AbstractGradient class into a new class, called ColorfulAbstractGradient.
  2. Edit the ColorfulAbstractGradient class, replacing all occurrences of “AbstractGradient” with “ColorfulAbstractGradient“.
  3. Add a method, randomColor, which you should implement to generate the random colors. Then add exactly one instruction to the paintOneDot method. Important: Do not remove any instructions. Do not modify any other instructions. Just add exactly one method and one instruction, 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 Dots

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

Write a variant of your ColorfulAbstractGradient 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 ColorfulAbstractGradient file to a newly established HirstDots file.
  2. Edit the HirstDots file by replacing all occurrences of “ColorfulAbstractGradient” by “HirstDots” and also modifying the leading comment.
  3. Change the input prompt which previously asked for the column width to one asking for the dot spacing.
  4. Do what needs to be done to your program to use the specified dot spacing for both the horizontal and vertical spacing. Be sure you’re updating your variable names to reflect the new functionality.

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

Problem 5: Simple Dots

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

  1. Copying and pasting the code from the HirstDots file to a newly established SimpleDots file.
  2. Edit the SimpleDots file by replacing all occurrences of “HirstDots” by “SimpleDots” and also modifying the leading comment.
  3. Arrange to accept one more item of information from a dialog box, a color name, either red or blue or green. You might like to consider doing this by securing the color input just after securing the other needed inputs, by calling an appropriately specific method analogous to the getNumber method, and then passing along the color to where it is needed in a cascading manner.
  4. Do what needs to be done to replace the randomly colored dots with the dots of the named color, or black dots should the user type in something other than the three specified color names.

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!

  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 circle and just one square. No rectangles. 4. It creates the exact same image every time it is run.
  4. There is some chance that the casual observer might find the image interesting!

Run it 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!

  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 rectangle.
  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: Stella


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

  1. The number of concentric 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 800 by 800 and the largest square will be 700 by 700.

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

The Exit

  1. Due date: Friday April 3, 2020
  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.