{"id":5217,"date":"2023-10-14T20:33:17","date_gmt":"2023-10-14T20:33:17","guid":{"rendered":"https:\/\/danielschlegel.org\/wp\/?page_id=5217"},"modified":"2023-10-15T15:41:45","modified_gmt":"2023-10-15T15:41:45","slug":"programming-challenge-4-nonrepresentational-artistic-expressions","status":"publish","type":"page","link":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2023\/programming-challenge-4-nonrepresentational-artistic-expressions\/","title":{"rendered":"Programming Challenge 4: Nonrepresentational Artistic Expressions"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Overview <\/h2>\n\n\n\n<p>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. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why do it?\n<\/h2>\n\n\n\n<p>By composing Java solutions to these non-representational artistic expression problems you will: <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Gain considerable practice in creating and using objects.<\/li>\n\n\n\n<li>Gain considerable practice in reading and understanding programs written by others.<\/li>\n\n\n\n<li>Gain considerable practice in program modification.<\/li>\n\n\n\n<li>Practice using selection and repetition constructs.<\/li>\n\n\n\n<li>Further explore the notion of creativity from constraint in the course of microworld problem solving. <\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">The Entrance\n<\/h2>\n\n\n\n<p>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. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\"> Problem 1: The Cave<\/h2>\n\n\n\n<p>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&#8217;re going to generate a piece of a map for one of these games. If you don&#8217;t like that kind of thing, you can think of this as just generating a nice little text-based image.<\/p>\n\n\n\n<p>Write a program called <tt>CaveMap<\/tt> in your <tt>npw<\/tt> 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: <\/p>\n\n\n\n<pre class=\"none\">run:\nEnter the width of the game map: 8\nEnter the width of the cave (must be less than the game map width): 5\n     ***\n*     **\n**     *\n***     \n**     *\n*     **\n     ***\n\nEnter the width of the game map: 10\nEnter the width of the cave (must be less than the game map width): 4\n    ******\n*    *****\n**    ****\n***    ***\n****    **\n*****    *\n******    \n*****    *\n****    **\n***    ***\n**    ****\n*    *****\n    ******\n\nEnter the width of the game map: 5\nEnter the width of the cave (must be less than the game map width): 1\n ****\n* ***\n** **\n*** *\n**** \n*** *\n** **\n* ***\n ****<\/pre>\n\n\n\n<p>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. <\/p>\n\n\n\n<pre class=\"java\">\n\/*\n * Program to draw a part of a map for a cave travelling game.\n * Game width and cave width are read from standard input.\n *\/\npackage npw;\n\nimport java.util.Scanner;\n\npublic class Cave {\n\n    public static void main(String[] args) {\n    }\n\n    public static void drawMap(int caveWidth, int gameWidth){\n        \/\/ Cave moving right...!\n        for (int i = 0; i < gameWidth - caveWidth; i = i + 1){\n            drawOneRow(i, caveWidth, gameWidth);\n            System.out.println();\n        }\n        \/\/ Cave moving left...!\n        for (int i = gameWidth - caveWidth; i >= 0; i = i - 1){\n            drawOneRow(i, caveWidth, gameWidth);\n            System.out.println();\n        }\n    }\n}\n <\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Problem 2: Entropy<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"741\" src=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-5.06.19-PM-1024x741.png\" alt=\"\" class=\"wp-image-5234\" style=\"width:600px\" srcset=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-5.06.19-PM-1024x741.png 1024w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-5.06.19-PM-300x217.png 300w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-5.06.19-PM-768x556.png 768w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-5.06.19-PM-1536x1112.png 1536w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-5.06.19-PM.png 2014w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p>Write a program called <tt>Entropy<\/tt> in your <tt>npw<\/tt> 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 (<strong>don&#8217;t copy\/paste!<\/strong>), run it several times, and <strong>study it<\/strong>! It&#8217;s important that you understand how it works for later parts of this assignment.<\/p>\n\n\n\n<pre class=\"java\">\n\/*\n * A program to paint an artistic representation of entropy in the NPW.\n *\/\npackage npw;\n\nimport painter.SPainter;\nimport shapes.SCircle;\nimport shapes.SSquare;\n\nimport javax.swing.*;\nimport java.awt.*;\nimport java.util.Scanner;\n\npublic class Entropy {\n\n    private void paintTheImage(){\n\n        \/\/ determine the canvas dimensions\n        int canvasHeight = getNumber(\"Canvas height\");\n        int canvasWidth = getNumber(\"Canvas width\");\n\n        \/\/ set up a circle (imagining a sphere-packing problem :)\n        \/\/   and get the square inscribing the circle so that the lattice\n        \/\/   will be just perfect.\n        int radius = getNumber(\"Diamond scale\");\n        SCircle invisibleCircle = new SCircle(radius);\n        SSquare sq = invisibleCircle.inscribingSquare();\n\n        \/\/ instantiate the painter and canvas\n        SPainter cassatt = new SPainter(\"Entropy\", canvasWidth, canvasHeight);\n\n        \/\/ frame the canvas: we want a 10 unit frame of white on all sides.\n        int frameDepth = 10;\n\n        \/\/ compute the number of columns needed\n        \/\/ working canvas width \/ diameter of invisibleCircle\n        int totalNumberOfColumns = (int) ((canvasWidth-2*frameDepth)\/invisibleCircle.diameter());\n\n        \/\/ check the work and adjust horizontal frameDepth as needed.\n        int horizFrameDepth = (int) ((canvasWidth - (totalNumberOfColumns * invisibleCircle.diameter())) \/ 2);\n\n        \/\/ compute the number of squares needed per column\n        int numberOfSquaresPerColumn = (int) ((canvasHeight - 2*frameDepth)\/invisibleCircle.diameter());\n\n        \/\/ check the work and adjust the vertical frameDepth as needed\n        int vertFrameDepth = (int) ((canvasHeight - (numberOfSquaresPerColumn * invisibleCircle.diameter())) \/ 2);\n\n        \/\/ move the painter to the top left of the working canvas area\n        \/\/    remember, painter began at center of canvas\n        cassatt.mfd(0.5*canvasHeight-vertFrameDepth);\n        cassatt.mlt(0.5*canvasWidth-horizFrameDepth);\n\n        \/\/ center the painter over the first column\n        cassatt.mrt(invisibleCircle.radius());\n\n        \/\/ track the number of columns painted\n        int colNumber = 0;\n\n        \/\/ introduce a chaos factor to change things up\n        double chaosFactor = 0;\n\n        while (colNumber < totalNumberOfColumns){\n            \/\/ set the color for the column\n            cassatt.setColor(chooseColor());\n\n            \/\/ paint a column\n            paintOneColumn(cassatt,sq,numberOfSquaresPerColumn, chaosFactor);\n\n            \/\/ center the painter over the next column\n            cassatt.mrt(invisibleCircle.diameter());\n            colNumber = colNumber + 1;\n            chaosFactor = (1.0\/totalNumberOfColumns)*colNumber;\n        }\n    }\n\n    private Color chooseColor() {\n        return Color.BLACK;\n    }\n\n    private void paintOneColumn(SPainter cassatt, SSquare sq, int numberOfSquaresPerColumn, double chaosFactor) {\n        \/\/ move down enough to paint the first square\n        cassatt.mbk(sq.diagonal()*0.5);\n\n        \/\/ track the amount of distance travelled\n        double distanceTraveled = sq.diagonal()*0.5;\n\n        \/\/ track the number of squares that get painted in the column\n        int squareNumber = 0;\n        while(squareNumber < numberOfSquaresPerColumn){\n\n            \/\/ paint a square, but as a diamond\n            paintOneDiamond(cassatt,sq,chaosFactor);\n\n            \/\/ move down\n            cassatt.mbk(sq.diagonal());\n\n            \/\/ track distance covered\n            distanceTraveled = distanceTraveled + sq.diagonal();\n\n            \/\/ track number of squares painted so far\n            squareNumber = squareNumber + 1;\n        }\n\n        \/\/ make sure the painter is invariant wrt position\n        cassatt.mfd(distanceTraveled);\n    }\n\n    private void paintOneDiamond(SPainter cassatt, SSquare sq, double chaosFactor) {\n\n        \/\/ set the default values\n        double origSquareSide = sq.side();\n        double rotationOffset = 0;\n        double offsetDirection = 0;\n        double offsetDistance = 0;\n\n        \/\/ when the chaosFactor is high enough, redefine the key values (sometimes)\n        if (chaosFactor > 0.3){\n            \/\/ flip the coin!\n            double probability = Math.random();\n\n            \/\/ for a heads, offset the diamond rotation a bit\n            if (probability > 0.5){\n                rotationOffset = (Math.random()*30)-15;\n            }\n        }\n\n        if(chaosFactor > 0.5){\n            \/\/ flip the coin!\n            double probability = Math.random();\n\n            \/\/ for a heads, change the size of the diamond a little bit\n            if (probability > 0.5){\n                double shrinkRate = (1 - probability)*0.7;\n                sq.resetSide((int) ((1-shrinkRate)*origSquareSide));\n            }\n        }\n\n        if (chaosFactor > 0.75){\n            \/\/ flip a coin!\n            double probability = Math.random();\n\n            if (chaosFactor > 0.9){\n                if (probability > 0.5){\n                    offsetDirection = Math.random()*360;\n                    offsetDistance = (Math.random()*(sq.diagonal()*0.5))*chaosFactor;\n                }\n            } else {\n\n                \/\/ for a heads, paint the diamond off center\n                if (probability > 0.5) {\n                    offsetDirection = Math.random() * 360;\n                    offsetDistance = (Math.random() * (sq.diagonal() * 0.5)) * 0.4;\n                }\n            }\n        }\n\n        \/\/ move the painter off center from the circle\n        cassatt.tr(offsetDirection);\n        cassatt.mfd(offsetDistance);\n        cassatt.tl(offsetDirection);\n\n        \/\/ rotate so that the square becomes a diamond\n        cassatt.tr(45+rotationOffset);\n\n        \/\/ paint\n        cassatt.paint(sq);\n\n        \/\/ rotate back!\n        cassatt.tl(45+rotationOffset);\n\n        \/\/ move the painter back to the center of the circle\n        cassatt.tr(offsetDirection);\n        cassatt.mbk(offsetDistance);\n        cassatt.tl(offsetDirection);\n\n        \/\/ if the square's side was adjusted, put it back\n        sq.resetSide((int) origSquareSide);\n    }\n\n    private static int getNumber(String prompt) {\n        String nss = JOptionPane.showInputDialog(null,prompt+\"?\");\n        Scanner scanner = new Scanner(nss);\n        return scanner.nextInt();\n    }\n\n    \/\/ REQUIRED INFRASTRUCTURE\n\n    public Entropy(){\n        paintTheImage();\n    }\n\n    public static void main(String[] args){\n        SwingUtilities.invokeLater(new Runnable(){\n            public void run () {\n                new Entropy();\n            }\n        });\n    }\n}\n\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Problem 3: Entropy in Color<\/h2>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1002\" height=\"1024\" data-id=\"5233\" src=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-14-16-10-17-1002x1024.png\" alt=\"\" class=\"wp-image-5233\" srcset=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-14-16-10-17-1002x1024.png 1002w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-14-16-10-17-294x300.png 294w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-14-16-10-17-768x785.png 768w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-14-16-10-17-1503x1536.png 1503w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-14-16-10-17-2004x2048.png 2004w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-14-16-10-17.png 2033w\" sizes=\"auto, (max-width: 1002px) 100vw, 1002px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"923\" data-id=\"5231\" src=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-5.01.07-PM-1-1024x923.png\" alt=\"\" class=\"wp-image-5231\" srcset=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-5.01.07-PM-1-1024x923.png 1024w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-5.01.07-PM-1-300x270.png 300w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-5.01.07-PM-1-768x692.png 768w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-5.01.07-PM-1-1536x1384.png 1536w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-5.01.07-PM-1.png 1620w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"853\" height=\"1024\" data-id=\"5232\" src=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-4.57.22-PM-1-853x1024.png\" alt=\"\" class=\"wp-image-5232\" srcset=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-4.57.22-PM-1-853x1024.png 853w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-4.57.22-PM-1-250x300.png 250w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-4.57.22-PM-1-768x922.png 768w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-4.57.22-PM-1.png 1216w\" sizes=\"auto, (max-width: 853px) 100vw, 853px\" \/><\/figure>\n<\/figure>\n\n\n\n<p>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:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Copy the code from the <tt>Entropy<\/tt> class into a new class, called <tt>EntropyInColor<\/tt>. <\/li>\n\n\n\n<li>Edit the <tt>EntropyInColor<\/tt> class, replacing all occurrences of &#8220;<tt>Entropy<\/tt>&#8221; with &#8220;<tt>EntropyInColor<\/tt>&#8220;.<\/li>\n\n\n\n<li>Modify the <tt>chooseColor<\/tt> method to pick a color based at least in part on the chaosFactor. Be sure to modify the call to this method appropriately. <strong>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. <\/strong><\/li>\n<\/ol>\n\n\n\n<p>Of course you will want to run your program a number of times to be sure it&#8217;s doing what it&#8217;s supposed to.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Problem 4: Hirst Lattice<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"989\" height=\"1024\" src=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-14-16-26-20-989x1024.png\" alt=\"\" class=\"wp-image-5238\" style=\"width:600px\" srcset=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-14-16-26-20-989x1024.png 989w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-14-16-26-20-290x300.png 290w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-14-16-26-20-768x795.png 768w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-14-16-26-20-1484x1536.png 1484w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-14-16-26-20.png 1531w\" sizes=\"auto, (max-width: 989px) 100vw, 989px\" \/><\/figure>\n<\/div>\n\n\n<p>Write a variant of your <tt>EntropyInColor<\/tt> class in your <tt>npw<\/tt> package which paints images like the one shown. Call this program <tt>HirstLattice<\/tt>. Moreover, do this task by: <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Copying and pasting the code from the <tt>EntropyInColor<\/tt> file to a newly established <tt>HirstLattice<\/tt> file. <\/li>\n\n\n\n<li>Edit the <tt>HirstLattice<\/tt> file by replacing all occurrences of \u201c<tt>EntropyInColor<\/tt>\u201d by \u201c<tt>HirstLattice<\/tt>\u201d and also modifying the leading comment. <\/li>\n\n\n\n<li>Replace the <tt>chooseColor<\/tt> method with the <tt>randomColor<\/tt> method we&#8217;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.<\/li>\n<\/ol>\n\n\n\n<p>Run your program a number of times to see that it is doing what it is supposed to do. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Problem 5: Hirst Dots  <\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"642\" src=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2019\/03\/image-4-1024x642.png\" alt=\"\" class=\"wp-image-2470\" srcset=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2019\/03\/image-4-1024x642.png 1024w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2019\/03\/image-4-300x188.png 300w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2019\/03\/image-4-768x481.png 768w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2019\/03\/image-4.png 2024w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>This one requires a couple clever thoughts! Be sure you have read and understand all of the code in the previous two problems.<\/p>\n\n\n\n<p>Write a variant of your <tt>HirstLattice<\/tt> class in your <tt>npw<\/tt> package which paints images like the one shown. Call this program <tt>HirstDots<\/tt>. Moreover, do this task by: <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Copying and pasting the code from the <tt>HirstLattice<\/tt> file to a newly established <tt>HirstDots<\/tt> file. <\/li>\n\n\n\n<li>Edit the <tt>HirstDots<\/tt> file by replacing all occurrences of \u201c<tt>HirstLattice<\/tt>\u201d by \u201c<tt>HirstDots<\/tt>\u201d and also modifying the leading comment. <\/li>\n\n\n\n<li>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.<\/li>\n<\/ol>\n\n\n\n<p>Run your program a number of times to see that it is doing what it is supposed to do. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Problem 6: Deterministic Invention <\/h2>\n\n\n\n<p>Write a program called <tt>Invention1<\/tt> in your <tt>npw<\/tt> package which paints an image subject to the following constraints. <strong>Do not just modify the above programs in 2-5 &#8211; make your own thing! Your invention should be significantly different from other students&#8217; inventions!<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>It uses at least one while statement in a nontrivial way.<\/li>\n\n\n\n<li>It uses at least one if statement in a nontrivial way.<\/li>\n\n\n\n<li>It features both circles and squares, all created from just one SCircle and just one SSquare. No SRectangles.<\/li>\n\n\n\n<li>It creates the exact same image every time it is run.<\/li>\n\n\n\n<li>There is some chance that the casual observer might find the image interesting! <\/li>\n<\/ol>\n\n\n\n<p>Run it (at least) twice to make sure the output is the same each time you run the program. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Problem 7: Nondeterministic Invention <\/h2>\n\n\n\n<p>Write a program called <tt>Invention2<\/tt> in your <tt>npw<\/tt> package which paints an image subject to the following constraints. <strong>Do not just modify the above programs in 2-5 &#8211; make your own thing! Your invention should be significantly different from other students&#8217; inventions!<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>It uses at least one while statement in a nontrivial way.<\/li>\n\n\n\n<li>It uses at least one if statement in a nontrivial way. <\/li>\n\n\n\n<li>It features solely rectangles, all generated from a single SRectangle.<\/li>\n\n\n\n<li>The program takes no input from the user of the program. <\/li>\n\n\n\n<li>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. <\/li>\n\n\n\n<li>There is some chance that the casual observer might find the image interesting! <\/li>\n<\/ol>\n\n\n\n<p>Run it twice to make sure the output is not the same each time you run the program. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Problem 8: Pinwheel<\/h2>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"993\" height=\"1024\" data-id=\"5218\" src=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/pinwheel_1-993x1024.png\" alt=\"\" class=\"wp-image-5218\" srcset=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/pinwheel_1-993x1024.png 993w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/pinwheel_1-291x300.png 291w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/pinwheel_1-768x792.png 768w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/pinwheel_1.png 1424w\" sizes=\"auto, (max-width: 993px) 100vw, 993px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"993\" height=\"1024\" data-id=\"5219\" src=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/pinwheel_2-993x1024.png\" alt=\"\" class=\"wp-image-5219\" srcset=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/pinwheel_2-993x1024.png 993w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/pinwheel_2-291x300.png 291w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/pinwheel_2-768x792.png 768w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/pinwheel_2.png 1424w\" sizes=\"auto, (max-width: 993px) 100vw, 993px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"993\" height=\"1024\" data-id=\"5220\" src=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/pinwheel_3-993x1024.png\" alt=\"\" class=\"wp-image-5220\" srcset=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/pinwheel_3-993x1024.png 993w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/pinwheel_3-291x300.png 291w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/pinwheel_3-768x792.png 768w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/pinwheel_3.png 1424w\" sizes=\"auto, (max-width: 993px) 100vw, 993px\" \/><\/figure>\n<\/figure>\n\n\n\n<p>Write a program called <tt>Pinwheel<\/tt> in your <tt>npw<\/tt> package which paints images like the ones just presented. The constraints are these: <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The number of squares will be read from a dialog box.<\/li>\n\n\n\n<li>Two randomly chosen colors will be used for the image that is painted when the program is run. <\/li>\n\n\n\n<li>The canvas will be of size 600 by 600 and the square will be 400 by 400. <\/li>\n<\/ol>\n\n\n\n<p>Run the program several times, doing your best to enjoy looking at the output.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Exit\n<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li> Due date: Tuesday October 31, 2023.<\/li>\n\n\n\n<li> Once you are ready, you must demo your programs for one of the TAs. <\/li>\n\n\n\n<li> 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 <strong>before you demo<\/strong> in order to receive credit.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p class=\"lead\">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,&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"btn btn-warning\" href=\"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2023\/programming-challenge-4-nonrepresentational-artistic-expressions\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":5064,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_editorskit_title_hidden":false,"_editorskit_reading_time":7,"_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","footnotes":""},"class_list":["post-5217","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Programming Challenge 4: Nonrepresentational Artistic Expressions - Daniel R. Schlegel<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2023\/programming-challenge-4-nonrepresentational-artistic-expressions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Programming Challenge 4: Nonrepresentational Artistic Expressions - Daniel R. Schlegel\" \/>\n<meta property=\"og:description\" content=\"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,&hellip;Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2023\/programming-challenge-4-nonrepresentational-artistic-expressions\/\" \/>\n<meta property=\"og:site_name\" content=\"Daniel R. Schlegel\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-15T15:41:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-5.06.19-PM-1024x741.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc212-fall-2023\\\/programming-challenge-4-nonrepresentational-artistic-expressions\\\/\",\"url\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc212-fall-2023\\\/programming-challenge-4-nonrepresentational-artistic-expressions\\\/\",\"name\":\"Programming Challenge 4: Nonrepresentational Artistic Expressions - Daniel R. Schlegel\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc212-fall-2023\\\/programming-challenge-4-nonrepresentational-artistic-expressions\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc212-fall-2023\\\/programming-challenge-4-nonrepresentational-artistic-expressions\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/Screenshot-2023-10-13-at-5.06.19-PM-1024x741.png\",\"datePublished\":\"2023-10-14T20:33:17+00:00\",\"dateModified\":\"2023-10-15T15:41:45+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc212-fall-2023\\\/programming-challenge-4-nonrepresentational-artistic-expressions\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc212-fall-2023\\\/programming-challenge-4-nonrepresentational-artistic-expressions\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc212-fall-2023\\\/programming-challenge-4-nonrepresentational-artistic-expressions\\\/#primaryimage\",\"url\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/Screenshot-2023-10-13-at-5.06.19-PM.png\",\"contentUrl\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/Screenshot-2023-10-13-at-5.06.19-PM.png\",\"width\":2014,\"height\":1458},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc212-fall-2023\\\/programming-challenge-4-nonrepresentational-artistic-expressions\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Teaching\",\"item\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"CSC212 &#8211; Fall 2023\",\"item\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc212-fall-2023\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Programming Challenge 4: Nonrepresentational Artistic Expressions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/#website\",\"url\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/\",\"name\":\"Daniel R. Schlegel\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Programming Challenge 4: Nonrepresentational Artistic Expressions - Daniel R. Schlegel","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2023\/programming-challenge-4-nonrepresentational-artistic-expressions\/","og_locale":"en_US","og_type":"article","og_title":"Programming Challenge 4: Nonrepresentational Artistic Expressions - Daniel R. Schlegel","og_description":"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,&hellip;Read more","og_url":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2023\/programming-challenge-4-nonrepresentational-artistic-expressions\/","og_site_name":"Daniel R. Schlegel","article_modified_time":"2023-10-15T15:41:45+00:00","og_image":[{"url":"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-5.06.19-PM-1024x741.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2023\/programming-challenge-4-nonrepresentational-artistic-expressions\/","url":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2023\/programming-challenge-4-nonrepresentational-artistic-expressions\/","name":"Programming Challenge 4: Nonrepresentational Artistic Expressions - Daniel R. Schlegel","isPartOf":{"@id":"https:\/\/danielschlegel.org\/wp\/#website"},"primaryImageOfPage":{"@id":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2023\/programming-challenge-4-nonrepresentational-artistic-expressions\/#primaryimage"},"image":{"@id":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2023\/programming-challenge-4-nonrepresentational-artistic-expressions\/#primaryimage"},"thumbnailUrl":"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-5.06.19-PM-1024x741.png","datePublished":"2023-10-14T20:33:17+00:00","dateModified":"2023-10-15T15:41:45+00:00","breadcrumb":{"@id":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2023\/programming-challenge-4-nonrepresentational-artistic-expressions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2023\/programming-challenge-4-nonrepresentational-artistic-expressions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2023\/programming-challenge-4-nonrepresentational-artistic-expressions\/#primaryimage","url":"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-5.06.19-PM.png","contentUrl":"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-13-at-5.06.19-PM.png","width":2014,"height":1458},{"@type":"BreadcrumbList","@id":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2023\/programming-challenge-4-nonrepresentational-artistic-expressions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/danielschlegel.org\/wp\/"},{"@type":"ListItem","position":2,"name":"Teaching","item":"https:\/\/danielschlegel.org\/wp\/teaching\/"},{"@type":"ListItem","position":3,"name":"CSC212 &#8211; Fall 2023","item":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2023\/"},{"@type":"ListItem","position":4,"name":"Programming Challenge 4: Nonrepresentational Artistic Expressions"}]},{"@type":"WebSite","@id":"https:\/\/danielschlegel.org\/wp\/#website","url":"https:\/\/danielschlegel.org\/wp\/","name":"Daniel R. Schlegel","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/danielschlegel.org\/wp\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/P83Tb6-1m9","_links":{"self":[{"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/pages\/5217","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/comments?post=5217"}],"version-history":[{"count":23,"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/pages\/5217\/revisions"}],"predecessor-version":[{"id":5251,"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/pages\/5217\/revisions\/5251"}],"up":[{"embeddable":true,"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/pages\/5064"}],"wp:attachment":[{"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/media?parent=5217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}