WXME0107 ## .wxtextwxtabwxmediawximage"(lib "syntax-browser.ss" "mrlib")drscheme:number$(lib "comment-snip.ss" "framework")+(lib "collapsed-snipclass.ss" "framework")drscheme:sexp-snip!(lib "bullet-snip.ss" "browser")drscheme:bindings-snipclass%$(lib "cache-image-snip.ss" "mrlib")drscheme:lambda-snip%gb:core gb:canvasgb:editor-canvas gb:slider gb:gauge gb:listbox gb:radiobox gb:choicegb:text gb:message gb:button gb:checkboxgb:vertical-panel gb:panelgb:horizontal-panel!(lib "readable.ss" "guibuilder")java-comment-box%java-interactions-box%make-line-snipmake-line-snip example-box%interactions-box%-(lib "image-snipr.ss" "slideshow" "private")drscheme:pict-value-snip%&(lib "pict-snipclass.ss" "slideshow")"drscheme:vertical-separator-snip%wxbaddrscheme:xml-snip(lib "xml-snipclass.ss" "xml")drscheme:scheme-snip"(lib "scheme-snipclass.ss" "xml")test-case-box% text-box%wxloc4K ZÁÿZÁÿÁÿ€ÿ€ÿ€ÿÁÿ StandardK Courier NewZÁÿZÁÿÁÿ€ÿ€ÿ€ÿÁÿÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð?ð?ð?ðÁÿÁÿframework:default-colorÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð?ð?ð?ðÁÿÁÿÁÿ?ð\ÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð"€‹"ÁÿÁÿMatching Parenthesis StyleÁÿ?ð\ÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð"€‹"ÁÿÁÿÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð&&€€ÁÿÁÿ(framework:syntax-coloring:scheme:symbolÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð&&€€ÁÿÁÿ)framework:syntax-coloring:scheme:keywordÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð&&€€ÁÿÁÿÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð€ÂtÁÿÁÿ)framework:syntax-coloring:scheme:commentÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð€ÂtÁÿÁÿÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð)€€&ÁÿÁÿ(framework:syntax-coloring:scheme:stringÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð)€€&ÁÿÁÿ*framework:syntax-coloring:scheme:constantÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð)€€&ÁÿÁÿÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð€„<$ÁÿÁÿ-framework:syntax-coloring:scheme:parenthesisÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð€„<$ÁÿÁÿÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð€ÿÁÿÁÿ'framework:syntax-coloring:scheme:errorÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð€ÿÁÿÁÿÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ðÁÿÁÿ'framework:syntax-coloring:scheme:otherÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ðÁÿÁÿÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ðQp€ËÁÿÁÿ1drscheme:check-syntax:lexically-bound-identifierÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ðQp€ËÁÿÁÿÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ðD€ËÁÿÁÿ*drscheme:check-syntax:imported-identifierÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ðD€ËÁÿÁÿ%profj:syntax-coloring:scheme:keywordÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ðÁÿÁÿÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð"€‹"ÁÿÁÿ$profj:syntax-coloring:scheme:stringÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð"€‹"ÁÿÁÿ%profj:syntax-coloring:scheme:literalÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð"€‹"ÁÿÁÿÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð€ã€ˆÁÿÁÿ%profj:syntax-coloring:scheme:commentÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð€ã€ˆÁÿÁÿ#profj:syntax-coloring:scheme:errorÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð€ÿÁÿÁÿÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð65€ÃÁÿÁÿ(profj:syntax-coloring:scheme:identifierÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð65€ÃÁÿÁÿ%profj:syntax-coloring:scheme:defaultÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ðÁÿÁÿF?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð?ð?ð?ðÁÿÁÿXMLF?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð?ð?ð?ðÁÿÁÿÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð€–€–ÁÿÁÿÁÿ?ðÁÿÁÿ]ÁÿÁÿÁÿ?ð?ð?ð€ÿÁÿÁÿÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð€¯ÁÿÁÿG?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð?ð?ð?ðÁÿÁÿÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð€ÿÁÿÁÿG?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð€ÿÁÿÁÿG?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ðdÁÿÁÿÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð€ÈÁÿÁÿG?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð?ð?ð?ðÁÿÁÿÁÿ?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð€ÿÁÿÁÿG?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ð€ÿÁÿÁÿG?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ðdÁÿÁÿK Courier NewZÁÿZÁÿÁÿ€ÿ€ÿ€ÿÁÿK?ðÁÿÁÿÁÿÁÿÁÿÁÿ?ð?ð?ðdÁÿÁÿK Courier NewZÁÿZÁÿÁÿ€ÿ€ÿ€ÿÁÿ,„/* Homework Solution 1 - Part 1  X 1) Many years of programming, using Scheme, ML, Haskell, Java, C, C++, Sparc-assembly Z Largest program: 10,000+ lines, the Java environment you guys are using (so if there  are problems, let me know)  5 2) Is an airplane in range of a given destination? R Important info: airplane's current position, amount of fuel on the airplane, U how many units of distance the plane flies on one unit of fuel, 7 location of specified destination  N 3) a) Movie information: title, genre, is it in stock?, when's it due back?  b) +------------------+  | Movie |  +------------------+  |String title |  |String genre |  |boolean isInStock |  |int dueDate |  +------------------+  " 4) Formal data design of a city  +------------------+  | City |  +------------------+  |double lattitude |  |double longitude |  |int cityRadius |  +------------------+   5) Formal design of a taco  +------------------+  | Taco |  +------------------+  |int ounceFilling1 |  |int ounceFilling2 |  |int ounceFilling3 |  +------------------+   6) Formal design of an office  +-----------------+  | Office |  +-----------------+  |String occupant |  |boolean isClean |  |String cleanedBy |  |String decore |  +-----------------+  ) 7) a) Formal design of the Bird class  +-----------------+  | Bird |  +-----------------+  |int age |  |String color |  +-----------------+ M b) Extend bird design so it can categorize birds into large and small  +-----------------+  | Bird |  +-----------------+  |int age |  |String color |  |int weight |  +-----------------+ 8 c) yellow 3 year-old bird:: new Bird(3,"yellow") 2 red 5 year-old bird:: new Bird(5,"red") ' d) 5 + new Bird(3,"yellow").age $ 5 + new Bird(5,"red").age ! 8) a) Formal design for Planet  +--------------------+  | Planet |  +--------------------+  |double avgDistToSun |  |int population |  +--------------------+  O b) Is there sufficient information to compute the population density? no  +--------------------+  | Planet |  +--------------------+  |double avgDistToSun |  |int population |  |double surfaceArea |  +--------------------+ \ c) An additional field needs to be added to the class, and then the constructor needs 6 to be updated in two places to reflect that:  class Planet {  double avgDistToSun;  int population; 4 double surfaceArea; //This must be added O Planet( double avgDistToSun, int population, double surfaceArea ) { Q // -------------------- added 1 this.avgDistToSun = avgDistToSun; - this.population = population; 7 this.surfaceArea = surfaceArea; //added  }  }  > d) Java to add the populations of two planets together S new Planet(1.0,4000,20).population + new Planet(2.0,45000,50).population  */  // Homework Solution 1 Part 2 ! //Question 1 part 3/b  class !Movie {  !String !title";  !String !genre";  boolean ! isInStock";  int !dueDate";" " " !Movie(! String title", ! String genre", boolean ! isInStock", int !dueDate) {  this".!title = !title";" " this".!genre = !genre";" " this".! isInStock = ! isInStock";" " this".!dueDate = !dueDate";" " }  //data examples 5 //new Movie("Gone with the wind","classic",false,12) , //new Movie("Spirited away","anime",true,0) }  //part 4  class !City {  double ! lattitude";  double ! longitude";  int ! cityRadius";" " " !City ( double ! lattitude", double ! longitude", int ! cityRadius ) {  this".! lattitude = ! lattitude";" " this".! longitude = ! longitude";" " this".! cityRadius = ! cityRadius";" " }  //new City( 44.35, 55.25, 40) }  //part 5 class !Taco {  int ! ounceFilling1";  int ! ounceFilling2";  int ! ounceFilling3";" " " !Taco( int ! ounceFilling1", int ! ounceFilling2", int !ounceFilling3 ) {  this".!ounceFilling1 = ! ounceFilling1";"  this".!ounceFilling2 = ! ounceFilling2";  this".!ounceFilling3 = ! ounceFilling3";  }  //new Taco(1,3,2) }  //part 6 class !Office {  !String !occupant";  boolean !isClean";  !String ! cleanedBy";  !String !decore";" " " !Office( !String occupant", boolean !isClean", !String cleanedBy", ! String decore) {  this".! occupant = !occupant";" " this".!isClean = !isClean";" " this".! cleanedBy = ! cleanedBy";" " this".!decore = !decore";" " }  *//new Office("Kathy",true,"Frank","white") 0 //new Office("Robby",true,"Fred","wood panel") }   //Question 2  class !Bird {  int !age";" " ! String color";" " int !size";" " " !Bird(int !age", ! String color", int !size) {  this".!age = !age";" " this".!color = !color";! ! this".!size = !size";" " }   *//new Bird(3,"yellow",5).isSmall() == true * //new Bird(5,"red",6).isSmall() == false  +//To determine if this Bird is a small bird  boolean !isSmall() {   0// ... this.age ... this.color ... this.size ...   return this".!size < 6";" " }   //Question 3   , //new Bird(3,"yellow",5).canFly(2) == true - //new Bird(3,"yellow",5).canFly(4) == false - //new Bird(5,"yellow",6).canFly(2) == false  boolean !canFly( int !minimumFlyingAge ) {  ?// ... this.age ... this.color ... this.size ... this.isSmall()   return (this".!age >= !minimumFlyingAge ) && this".!isSmall()";" " } } //Tests for isSmall ,¿ new Bird(3, "yellow",5).isSmall()true ,Ûnew Bird(5, "red",6).isSmall()false //Tests for canFly ,Énew Bird(3, "yellow",5).canFly(2)true ,Ïnew Bird(3, "yellow",5).canFly(4)false ,»new Bird(5, "yellow",6).canFly(2)false   //Question 4 class !Planet {  double ! avgDistToSun";  int ! population";  !Planet( double ! avgDistToSun", int ! population) {  this".! avgDistToSun = ! avgDistToSun";  this".! population = ! population";  }   //new Planet(1.0,3).add(30) == 33  9//To add a given number and the population of this Planet  int !add( int !number ) {   //... this.population ... number  return this".! population + !number";" " }   A//new Planet(4.5,10000).totalPop( new Planet(5.6,50000)) == 60000 < //new Planet(3,100).totalPop( new Planet(3.2,50) ) == 150 C //To get the total population of this planet and the givenPlanet  int !totalPop( !Planet givenPlanet ) {  ///... this.avgDistToSun ... this.population ...  return ! givenPlanet".!add(this".! population)"; " " } }  ,¬ new Planet(1.0,3).add(30)33 ,þnew Planet(4.5,10000) .totalPop( new Planet(5.6,50000))60000 ,önew Planet(3,100) .totalPop( new Planet(3.2,50) )150   //Question 5  //New taco design /* +----------+  | Taco2 |  +----------+  |int cheese|  |int beef |  |int pork |  |int vege |  |int beans |  +----------+ */  class !Taco2 {  int !cheese";" " int !beef";" " int !pork";" " int !vege";" " int !beans";" " !Taco2( int !cheese", int !beef", int !pork", int !vege", int !beans ) {  this".!cheese = !cheese";" " this".!beef = !beef";" " this".!pork = !pork";" " this".!vege = !vege";" " this".!beans = !beans";" " }   +//new Taco2(3,2,0,1,0).moreCheese() == true . //new Taco2(1,2,0,3,0).moreCheese() == false > //To determine if this taco has more than an ounce of cheese  boolean ! moreCheese() {  K// ... this.cheese ... this.beef ... this.pork ... this.vege ... this.beans   return this".!cheese > 1";" " } } ,Ônew Taco2(3,2,0,1,0) .moreCheese()true ,Únew Taco2(1,2,0,3,0) .moreCheese()false  //Challenge Question  / * Data design  +----------------+  | Birdcage |  +----------------+  |boolean isSmall |  +----------------+  */  class ! Birdcage {  boolean !isSmall";" " " !Birdcage ( boolean !isSmall ) {  this".!isSmall = !isSmall";" " }   ?//new Birdcage(false).willFit( new Bird(3,"yellow",5) ) == true B //new Birdcage(false).willFit( new Bird(3,"yellow",15) ) == true @ //new Birdcage(true).willFit( new Bird(3,"yellow",5) ) == true B //new Birdcage(true).willFit( new Bird(3,"yellow",15) ) == false ; //To determine if the givenBird will fit in this birdcage  boolean !willFit( !Bird givenBird ) {  %// ... this.isSmall ... givenBird ...   return (!this".!isSmall ) || (this".!isSmall && ! givenBird".!isSmall())";  }  }  ,new Birdcage(false).willFit( new Bird(3, "yellow",5) )true ,new Birdcage(false).willFit( new Bird(3, "yellow",15) )true ,new Birdcage(true).willFit( new Bird(3, "yellow",5) )true ,new Birdcage(true).willFit( new Bird(3, "yellow",15) )false