View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Midterm Review - Sum2000

A midterm in 2340 is 4-5 questions like each of the below. Most of the questions below are from actual midterms in CS2390 and the CS2340 Sp2000 Midterm.

I recommend working together to figure out the solutions. I will check up on the discussions, but I won't provide answers where no answers are posted.

Unless you need to edit/repair something here, do not edit this page! Put your answers on the answer page. If you do edit this page, please be careful with the formatting. Thanks! Mark Guzdial


Design Critique



A friend is showing you his object-oriented analysis and design. Your job is to critique it. Whatís going wrong in each of these situations?

(a) (6) "Here are my CRC cards. This class here is named MapLinkedList and it is a collection of all the Map objects in the system..."

(b) (6) "Here is my object ProcessMap. It knows its Map and it does the basic processing needed to get it on my website..."

(c) (8) "But everything is controlled here by the MapManager object. No other object processes without confirming it with the MapManager."

Put your answers/comments/questions at Sum2000 Midterm Review: Design Critique

Write Smalltalk Code



Write workspace code (something I can select and say DoIt in the workspace) to draw the below figure. (Iím not worried about sizes or exactnessódraw two rectangles with the text inside.) (To remind you, Pens know how to up, down, go:, turn:, and north:. Strings know how to asDisplayText, and a DisplayText knows how to displayAt: a given point.)

Uploaded Image: cs2340.gif

Put your answers/comments/questions at Sum2000 Midterm Review: Write Smalltalk Code


UML Class Diagramming



Draw a UML class diagram for the set of classes described below.

Put your answers/comments/questions at Sum2000 Midterm Review: UML Class Diagramming


UI Toolkit Structure



Explain how the components of MVC are reflected in Morphic by answering the below questions.

A. (5) If the controller is essentially the "event loop," where is the event loop in Morphic?

B. (10) In MVC, we have the dependency mechanism (changed:/update:) for handling the update of the view upon changes in the model. Two questions: (I) Can we use this mechanism in Morphic? (II) If we chose not to use it, is there another mechanism to insure that the views update properly?

Put your answers/comments/questions at Sum2000 Midterm Review: UI Toolkit Structure


History of Objects




A. (7) How did an early drawing tool influence object-oriented thought?

B. (8) What do simulations have to do with the creation of C++?


Put your answers/comments/questions at Sum2000 Midterm Review: History of Objects


Swing as MVC


Swing is conceptually based on MVC (Model-View-Controller). Where is each part? Are models the same as in Squeak? Are views the same? Where is the controller? How are dependencies handled?

Put your answers/comments/questions at Sum2000 Midterm Review: Swing as MVC


O-O Systems


(a) What's a class? What's an instance?
(b) What's the difference between a class and instance method?
(c) What's the difference between a class and instance variable?
(d) What are the strengths and weaknesses of a prototype vs. class-based object system?

Put your answers/comments/questions at Sum2000 Midterm Review: O-O Systems

Hotel Doors OOA/D


You have been hired to design a door lock and tracking system for a hotel. These are doors that are opened with a key card that contains an encoded number of some sort. NOTE: The keys have no processor nor network connection. You can't "talk to" a key.


(a). Name at least two classes that you would need in the design for this system, and two classes that you might consider but would reject. Give your reasons for rejecting those two classes.

(b) On the back of this sheet or on a separate sheet that you attach to the exam (remember, each problem will be graded separately!), draw the CRC cards for this scenario:
A customer gets a card key, takes it to the door, puts it in the door lock which checks if it's valid, then the door opens because it is valid.


Put your answers/comments/questions at Sum2000 Midterm Review: Hotel Doors OOA/D


Analyze Student/Classroom Code


Imagine that I have a Student object in a Classroom object, something like this.

 | s c |
c := Classroom new name: 'CS2390'.
s := Student new name: 'Fred'; section: 'a'; number: '123456789'.
c add: s.
s := Student new name: 'Wilma'; section: 'b'; number: '3456789012'.
c add: s.
s := Student new name: 'Barney'; section: 'a'; number: '012345678'.
"...More code here..." 


a. (7 points) What would you say is the relationship between Student objects and the Classroom object is? Why?

b. (10 points) What attributes and services do you think that the Student and Classroom objects have, based on what you see in the above code?

Put your answers/comments/questions at Sum2000 Midterm Review: Analyze Student/Classroom Code

History of Object Systems



Put your answers/comments/questions at Sp2000 Midterm Review: History of Object Systems

Short Essays


a. Explain how object-oriented programming is related to simulations.

b. What is a CRC card? What are they good for? When do you use them?

c. Explain in what sense inheritance is a form of delegation.

d. Why is it useful to think about objects as "biological cells"? (Hint: Think about scalability and about modularity.)

Put your answers/comments/questions at Sum2000 Midterm Review: Short Essays

Reading Code


 | anArray aString |
anArray := #('abc' 'def' 'ghi','jkl').
aString := ''.
anArray do: [:each |
	aString := aString, each.].
Transcript show: aString.


a. What appears on the Transcript ?

b. How many times did the do: loop get executed?
 | i test |
i := 1.
test := (i < 10).
[test] whileTrue: [Transcript show: 'hello'.
	i := i + 1.].

c. How many times does hello get printed in this example?

Put your answers/comments/questions at Sum2000 Midterm Review: Reading Code


Definitions


Define each and give an example.

a. What is Inheritance?

b. What is Delegation?

c. What is Polymorphism?

Put your answers/comments/questions at Sum2000 Midterm Review: Definitions

Draw a Class Diagram of a Student Registration System


You have just completed an analysis of a student registration system:


Draw a class diagram for these classes.

Put your answers/comments/questions at Sum2000 Midterm Review: Draw a Class Diagram of a Student Registration System


Simulate a Motorcycle



Imagine an object-oriented simulation of a motorcycle.


What instance variables are you going to need for each of the key, engine, and wheel classes?

(b) Write the methods insert for key; start and run for engine; and turn for the wheel.

(c) Write whatever accessor methods you need to make the above example work.

(d) Write the workspace code that you'd use to create the above scenario

Put your answers/comments/questions at
Sum2000 Midterm Review: Simulate a Motorcycle



Drawing in Smalltalk



1.Using Pen, write the code to draw an equilateral triangle.

2.Using the Box class, write the code to draw a pyramid of three boxes.

3.Explain what this code will do:

| joe |
joe := Box new.
30 timesRepeat: [joe turn: 12.]

Put your answers/comments/questions at Sum2000 Midterm Review: Drawing in Smalltalk

Analyze Robot Car



A robot is being designed to explore the surface of Mars autonomously.

External Image

Features of this robot include:


You are being asked to write some of the operating software for this robot.

Create a class diagram for the robot.


(You don't have to add more than what's in the above example.) Note: Partial credit will be given, so err on the side of too much, not too little. In your analysis, be sure to address:


Put your answers/comments/questions at Sum2000 Midterm Review: Analyzing the Robot Car

Code for Robot Car



Code for Robot Car: Here is part of the vehicle avoidance method for the robot:

 moveBackAfterBumpingFront: sensor
        sensor = 11
        ifTrue:
        [ "Assume that we1ve bumped our front left bumper"
        "Shift all wheels into reverse gear"   
        #('a' 'b' 'c' 'd' 'e' 'f') do: [:each | each shiftRear.]
        "Activate all wheels for one second."
        wheelsController activateFor: 1.
        "Shift left side wheels into forward gear."
        #('a' 'b' 'c') do: [:each | each shiftForward.].
        "Makes left wheels go forward while right wheels go reverse -- left turn."
        wheelsController activateFor: 1.
        ]. 
 

Write the analagous code for bumping the front right bumper.

        sensor = 1 ifTrue:
        [
Your code goes here
        ]  


Put your answers/comments/questions at Sum2000 Midterm Review: Coding the Robot Car

Links to this Page