CSG 107: Problem Set 7

Due: Wednesday, March 18, 2009 at 5:00 pm.

Purpose:

The goal of this problem set is to help you design simple class hierarchies and methods on them.

As always, you must follow the design recipe. We adapt the design recipe to ProfessorJ as follows:

Drill:

HtDC: 6.1-6.9, 10.1-10.4, 10.9, 11.2

Required Problems:

Note: You must use DrScheme's ProfessorJ Intermediate Student Language.

  1. Translate the data definitions from homework problem 2.1 into ProfessorJ. Since ProfessorJ doesn't have symbols, use Strings instead. Then design a method removeManufacturer that takes a manufacturer (represented as a String), and produces a list of inventory items just like this one, except that all the items by that manufacturer have been removed.

  2. Translate the data definitions from homework problem 2.2 into ProfessorJ. Design a method render that takes a Style and renders this list of strings in the given style.

    Since ProfessorJ's support for images is not as flexible as ISL's, render should produce another list of strings, each representing a line of the rendered image. For example if we started with an object representing the list of strings

    "You say goodbye"
    "I say hello"
    "hello, hello?"
    "I don't know why you say goodbye I say hello"
    
    and the style representing solid-dot, the result should be an object representing the list of strings
    "* You say goodbye"
    "* I say hello"
    "* hello, hello?"
    "* I don't know why you say goodbye I say hello"
    

    Optional: implement the number style from Homework 1.

  3. Create a representation of Matryoshka dolls, as in homework problem 2.3, in ProfessorJ. You need not follow the data representation from homework 2: what counts is that you create a data definition that captures the same information.

    Write three methods corresponding to the functions assemble, disassemble, and doll>?.

    As before, use strings instead of symbols. What additional classes will you need in your class diagram? To which classes should each of these methods belong?


Last modified: Wed Mar 04 16:35:47 2009