Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Discussion 4 - Sashmit Bhaduri
From Midterm Review - Sum2000:
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?
a). Classroom hasA Student. This is because Classroom presumably internally stores a 0 to n students (in some sort of collection).
Student -> services (the accessors aren't hinted by the code, but in a larger example, they'd likely be there)
students (some sort of collection)
name (not shown in code)
Links to this Page