Homework 1: Part 2

Due Monday June 27, 5:20pm


This portion of Homework 1 is expected to be turned in by e-mail. One file should be turned in, using comments to separate different answers. This file must run in the ProfessorJ: Beginner language level of DrScheme. Attach this file to an e-mail and send it to kathyg@cs.uchicago.edu with the subject : cspp50101-hw1

  1. Represent the formal designs from questions 3-b, 4, 5 and 6 in Part 1 of Homework 1 in Java. Create data examples for them.
  2. Using the Bird design from 7-b, represent the formal design in Java, and add a method that will determine whether the Bird is small. Follow the design recipe.
  3. Extend Bird, following the design recipe, to determine if the Bird can fly. The domain expert for this Bird states that only small Birds over a given age can fly.
  4. Following the design recipe, add a method to Planet from 8-a that adds the populations of the planet to the population of another planet.
  5. The taco vendor from question 5 in Part 1 wants to know whether or not the taco contains more than an ounce of cheese. Follow the design recipe to create this program. Modify your formal design if necessary.
  6. A pet store has cages of various sizes. The employees need to know if a given Bird will fit into the cage.  Following the design recipe, create the data and program the pet store needs.

Challenge

  1. A pet store employee is given two Birds, and needs to know which bird to put in the cage. Using the existing representations, write a program that will give the bird that didn't fit back to the employee. (One bird is assumed to always fit, if both will fit, the first bird given will be put in the bird cage).
  2. A spaceship is traveling to a Planet; the spaceship pilot needs to know if the spaceship will have permission to land on the Planet. Permission is granted if the name of the planet matches the destination of the spaceship and if the number of passengers on the spaceship is not greater than the unoccupied capacity of the planet. Follow the design recipe to create the data and program that the pilot needs.