{"id":4679,"date":"2022-09-13T15:32:20","date_gmt":"2022-09-13T15:32:20","guid":{"rendered":"https:\/\/danielschlegel.org\/wp\/?page_id=4679"},"modified":"2022-09-13T15:35:10","modified_gmt":"2022-09-13T15:35:10","slug":"programming-challenge-2-microworld-problem-solving","status":"publish","type":"page","link":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2022\/programming-challenge-2-microworld-problem-solving\/","title":{"rendered":"Programming Challenge 2: Microworld Problem Solving"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Overview<\/h3>\n\n\n\n<p>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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why do it?<\/h3>\n\n\n\n<p>By composing Java solutions to the problems in the context of the featured microworlds you will:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Gain considerable practice in creating and using objects.<\/li><li>Continue to get acquainted with elements of graphics programming and sonic programming.<\/li><li>Program, at least some of the time, in a manner that is consistent with the principle of stepwise refinement.<\/li><li>Make explicit use of the problem solving strategy of problem decomposition.<\/li><li>Write programs with invariance in mind.<\/li><li>Learn just a bit about how to work from language specifications.<\/li><li>Explore the notion creativity from constraint in the course of microworld problem solving.<\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">The Entrance<\/h3>\n\n\n\n<p>Please be sure to complete Lab 2 and Programming Challenge 1 before starting this assignment. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Problem 1: Fun Squares!<\/h3>\n\n\n\n<p>In the context of the NPW, write a program called FunSquares within the npw package to paint the colorful and fun image depicted below.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2022\/09\/image-993x1024.png\" alt=\"\" class=\"wp-image-4682\" width=\"497\" height=\"512\" srcset=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2022\/09\/image-993x1024.png 993w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2022\/09\/image-291x300.png 291w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2022\/09\/image-768x792.png 768w, https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2022\/09\/image.png 1424w\" sizes=\"auto, (max-width: 497px) 100vw, 497px\" \/><\/figure>\n<\/div>\n\n\n<p>Constraints:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Use the technique of modifying an existing program that does something similar. Do so by:<br>(a) Creating a new Java Main Class file for the program, naming it FunSquares and placing it in the npw package.<br>(b) Replacing the entire contents of the <tt>FunSquares<\/tt> file with the entire contents of the <tt>BlueDot<\/tt> program.<br>(c) Changing all occurrences of <tt>BlueDot<\/tt> to <tt>FunSquares<\/tt>.<\/li><li>Place the following code, without alteration, in the <tt>paintTheImage<\/tt> method. <pre class=\"java\">SPainter painter = new SPainter(\"Fun Squares\",600,600);\nSSquare square = new SSquare(150);\npaintYellowSquare(painter,square);\npaintRedSquares(painter,square);\npaintBlueSquares(painter,square);\npaintGraySquares(painter,square); <\/pre> Then:<br>(a) Use the features of IntelliJ to add the necessary import statements.<br>(b) Use the light bulbs to create a stub for each of the unrefined methods. (You should create 4 stubs.)<\/li><li>One at a time, complete the definitions of the methods, proceeding as follows:<br>(a) Run the program, and see that not much happens.<br>(b) Refine the <tt>paintYellowSquare<\/tt> method, <strong>being sure to make it invariant with respect to both the location and heading of the painter<\/strong>, run the program, enjoy the yellow square. <br>(c) Refine the <tt>paintRedSquares<\/tt> method, <strong>being sure to make it invariant with respect to both the location and heading of the painter<\/strong>, run the program, enjoy the yellow square and red squares.<br>(d) Refine the <tt>paintBlueSquares<\/tt> method, <strong>being sure to make it invariant with respect to both the location and heading of the painter<\/strong>, run the program, enjoy the yellow square, red squares and blue squares.<br>(e) Refine the <tt>paintGraySquares<\/tt> method, run the program, and enjoy looking at the fun squares! <\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Problem 2: Dots <\/h3>\n\n\n\n<p>In the context of the NPW, write a program called <tt>Dots<\/tt> within the <tt>npw<\/tt> package to paint an image consisting exclusively of dots (painted circles) subject to the following constraints:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>it contains exactly 11 painted (filled in) circles<\/li><li>it contains circles of exactly 4 different sizes<\/li><li>it contains circles of exactly 3 different colors<\/li><li>none of the circles touch<\/li><li>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)<\/li><li>not all of the circles touch the Y-axis<\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Problem 3: Musical Scene<\/h3>\n\n\n\n<p>Write a program called <tt>MusicalScene<\/tt> within the <tt>mmw<\/tt> package to play a melody composed exclusively of the sequences available in MMW which represent locations and locomotion, subject to the following additional constraints:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>The melody will consist of between 43 and 45 notes.<\/li><li>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!<\/li><li>You must ask the composer to raise its note at least once. <\/li><li>The final note will be a C note.<\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Due Date and Reminders<\/h3>\n\n\n\n<ol class=\"wp-block-list\"><li>Due date: Tuesday September 27, 2022<\/li><li>Once you are ready, you must <strong>demo<\/strong> your programs for one of the TAs.<\/li><li>You must post your work (source program and demo for each problem), to your Web Work Site. <strong>You will not receive any credit from the TAs until your work is posted on your Web Site!<\/strong><\/li><\/ol>\n","protected":false},"excerpt":{"rendered":"<p class=\"lead\">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&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"btn btn-warning\" href=\"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2022\/programming-challenge-2-microworld-problem-solving\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":4510,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_editorskit_title_hidden":false,"_editorskit_reading_time":3,"_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","footnotes":""},"class_list":["post-4679","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 2: Microworld Problem Solving - 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-2022\/programming-challenge-2-microworld-problem-solving\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Programming Challenge 2: Microworld Problem Solving - Daniel R. Schlegel\" \/>\n<meta property=\"og:description\" content=\"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&hellip;Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2022\/programming-challenge-2-microworld-problem-solving\/\" \/>\n<meta property=\"og:site_name\" content=\"Daniel R. Schlegel\" \/>\n<meta property=\"article:modified_time\" content=\"2022-09-13T15:35:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2022\/09\/image-993x1024.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=\"4 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-2022\\\/programming-challenge-2-microworld-problem-solving\\\/\",\"url\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc212-fall-2022\\\/programming-challenge-2-microworld-problem-solving\\\/\",\"name\":\"Programming Challenge 2: Microworld Problem Solving - Daniel R. Schlegel\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc212-fall-2022\\\/programming-challenge-2-microworld-problem-solving\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc212-fall-2022\\\/programming-challenge-2-microworld-problem-solving\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/image-993x1024.png\",\"datePublished\":\"2022-09-13T15:32:20+00:00\",\"dateModified\":\"2022-09-13T15:35:10+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc212-fall-2022\\\/programming-challenge-2-microworld-problem-solving\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc212-fall-2022\\\/programming-challenge-2-microworld-problem-solving\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc212-fall-2022\\\/programming-challenge-2-microworld-problem-solving\\\/#primaryimage\",\"url\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/image.png\",\"contentUrl\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/image.png\",\"width\":1424,\"height\":1468},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc212-fall-2022\\\/programming-challenge-2-microworld-problem-solving\\\/#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 2022\",\"item\":\"https:\\\/\\\/danielschlegel.org\\\/wp\\\/teaching\\\/csc212-fall-2022\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Programming Challenge 2: Microworld Problem Solving\"}]},{\"@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 2: Microworld Problem Solving - 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-2022\/programming-challenge-2-microworld-problem-solving\/","og_locale":"en_US","og_type":"article","og_title":"Programming Challenge 2: Microworld Problem Solving - Daniel R. Schlegel","og_description":"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&hellip;Read more","og_url":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2022\/programming-challenge-2-microworld-problem-solving\/","og_site_name":"Daniel R. Schlegel","article_modified_time":"2022-09-13T15:35:10+00:00","og_image":[{"url":"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2022\/09\/image-993x1024.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2022\/programming-challenge-2-microworld-problem-solving\/","url":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2022\/programming-challenge-2-microworld-problem-solving\/","name":"Programming Challenge 2: Microworld Problem Solving - Daniel R. Schlegel","isPartOf":{"@id":"https:\/\/danielschlegel.org\/wp\/#website"},"primaryImageOfPage":{"@id":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2022\/programming-challenge-2-microworld-problem-solving\/#primaryimage"},"image":{"@id":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2022\/programming-challenge-2-microworld-problem-solving\/#primaryimage"},"thumbnailUrl":"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2022\/09\/image-993x1024.png","datePublished":"2022-09-13T15:32:20+00:00","dateModified":"2022-09-13T15:35:10+00:00","breadcrumb":{"@id":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2022\/programming-challenge-2-microworld-problem-solving\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2022\/programming-challenge-2-microworld-problem-solving\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2022\/programming-challenge-2-microworld-problem-solving\/#primaryimage","url":"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2022\/09\/image.png","contentUrl":"https:\/\/danielschlegel.org\/wp\/wp-content\/uploads\/2022\/09\/image.png","width":1424,"height":1468},{"@type":"BreadcrumbList","@id":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2022\/programming-challenge-2-microworld-problem-solving\/#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 2022","item":"https:\/\/danielschlegel.org\/wp\/teaching\/csc212-fall-2022\/"},{"@type":"ListItem","position":4,"name":"Programming Challenge 2: Microworld Problem Solving"}]},{"@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-1dt","_links":{"self":[{"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/pages\/4679","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=4679"}],"version-history":[{"count":9,"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/pages\/4679\/revisions"}],"predecessor-version":[{"id":4690,"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/pages\/4679\/revisions\/4690"}],"up":[{"embeddable":true,"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/pages\/4510"}],"wp:attachment":[{"href":"https:\/\/danielschlegel.org\/wp\/wp-json\/wp\/v2\/media?parent=4679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}