Midterm Review

Typically, a midterm in 2390 is 4-5 questions like each of the below. Most of the questions below are from actual midterms in 2390. I recommend working together through the CaMILE links to figure out the solutions. I will check up on the discussions, but I won't provide answers where no answers are posted.

  1. . Macrosoft Corporation is creating a new suite of applications software, designed using an object-oriented approach with Smalltalk as the target language. You have been asked to do the initial analysis of the document needs for printing and saving documents.

    Your first thoughts on the analysis look something like this:

    I am a Document. I know how to save myself (to a filename), and I remember my base filename and directory path. I know how to open and close myself. I also know how to print myself, and I remember my printing parameters (such as landscape or portrait printing mode).

    I am a Word-Processing Document. I know what fonts I need, what my margins are, and what my header and footer is (if any). I know how to paginate myself.

    The below figure is a snapshot of what you're thinking about for the graphical notation, but it isn't yet complete (e.g., no decisions yet on what's concrete and what's abstract).


    A. You now need to extend your analysis to include Drawing Documents. Drawing Documents have text boxes that can use multiple fonts, and they have margins, but they don't usually have headers and footers. Drawing Documents also have to keep track of picture elements that they consist of: lines, rectangles, pasted-in bitmaps, etc. They do need to be able to paginate themselves. Show me (a) how you would describe the Drawing Document class in terms of the Coad & Nicola "I am a" notation and (b) how you would extend the graphical representation pictured above to include Drawing Documents. (Go ahead and use the back of this page.)(Just turn the monitor over...:-) Please describe in words how you would make these changes

    Post your answers, comments, questions, concerns, etc. here

  2. B. You now get word from the analysts working on text that they have defined a Paragraph class whose instances will know how to print themselves. You extend your WPDocument class to contain an OrderedCollection of paragraphs. The header and footer will also be instances of the class Paragraph. Write the print method for WPDocument which will (a) print the header, (b) print the paragraphs of the document, and (c) print the footer.

    Post your answers, comments, questions, concerns, etc. here

  3. The WhizO Toy Company is working on their first video game: A fighting game with dinosaurs. The figure below shows the result of their object-oriented analysis of the problem:

    In the below short answers, I expect to see the following terms used:

    Class

    Subclass

    Concrete and Abstract class

    Inheritance

    Gen-spec relationship

    Whole-part relationship

    Describe the relationship between:

    The Dinosaur and DinoParts classes.

    The Plateosaur and Raptor classes.

    The Dinosaur and Raptor classes.

    The size instance variable in the Dinosaur class, in the Plateosaur class, and in the Legs class.

    Post your answers, comments, questions, concerns, etc. here

  4. Below is the Smalltalk instance method which appears in the Dinosaur class:
    attack: target
    	| location |
    	location := target position.
    	self aim: position.
    	self useWeapon.
    

    This code might be used like this:

    | aRaptor aPtero |
    aRaptor := Raptor new.
    aPtero := Pterodactyl new.
    aRaptor attack: aPtero.
    
    • What is location?
    • What is target?
    • What is position? Where is position defined?
    • Assuming that the system was implemented as described in the OOA diagram presented earlier, could this code work? Explain why not, or explain what assumptions you need to make.

    Post your answers, comments, questions, concerns, etc. here

  5. Be able to explain the all-caps words in the following contexts:
    • Ascii Count is a SPECIALIZATION (SUBCLASS) of Count (SUPERCLASS), which means that it INHERITS the structure and behavior of Count.
    • Count is an ABSTRACT CLASS.
    • A CountViewContainer sends messages to a particular INSTANCE of IntegerCount.
    • Interfaces in Smalltalk are constructed from MODEL, VIEW, and CONTROLLER classes.

    Post your answers, comments, questions, concerns, etc. here

  6. Consider the Vending Machine simulation discussed in class. The list below identifies the classes which were the central ones in implementing the Vending Machine.
    • Identify which of these classes are models, which are views, and which are controllers.
    • Describe (textually) the cascade of messages which result from hitting the Select button in the CashDeviceViewContainer.
    Classes
    CashDevice
    CashDeviceViewContainer
    DisplayBox
    DisplayBoxController
    DispensingHolder
    Item
    ItemViewContainer
    ModelValueViewContainer
    

    Post your answers, comments, questions, concerns, etc. here

  7. You have been asked to create a simulation of an airport with a particular emphasis on modeling the flow of airplanes (e.g., how long does an airplane have to wait to land or to take-off?) Identify and Describe at least FIVE classes that you would need to (1) create the Problem Domain component and (2) create the Human Interface component.
    • Be sure to identify which are Problem Domain and which are Human Interface classes.
    • Be brief, but think about what it takes to describe a class.

    Post your answers, comments, questions, concerns, etc. here

  8. You are a consultant to the WhizO Toy Company ("Makers of toys for tots of all ages"). WhizO is considering a shift to an object-oriented software development process. If they do make such a shift, you're in for big bucks as the consultant who leads the way. First step is to respond to the specific concerns of the Manager of their Software Development unit:
    • "We usually have multiple teams of developers working on different parts of the programs at once. How does object-orientation help us with that?"
    • "We rely heavily on simulation when developing sophisticated toys. What would be absolutely perfect would be if we could take parts of our simulation and use it in the code for the real toy. Can we do that? How?"
    • "What happens if we develop add-ons for a toy, like a new Laser Gun for our Omega Video Game System? Or if we develop a new variation on a toy, like the Phaser Range Finder Gun (which is like the Laser Gun)? Can O-O help our productivity in doing this?"

    Post your answers, comments, questions, concerns, etc. here

  9. Below is one method from the Vending Machine simulation.
    • To what class does this code belong? What does it do?
    • Write a brief comment describing what each line of this code does.
    dispense: itemToDispense 
    
    	self isEmpty ifTrue: [^false].
    
    
    	(self itemIsDispensable: itemToDispense) ifFalse:
    		 [^false].
    
    
    	self printItem:  itemToDispense .
    
    
    	self activateDispenser.
    
    
    	self disconnectWithItem: itemToDispense.
    
    
    	^true
    

    Post your answers, comments, questions, concerns, etc. here