Change Contents of the Bubble
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Midterm exam 2 review Sp2006: Explore the UML

Comments, Questions, Answers, Questions about Answers?
(Back to Midterm Exam 2 Review Sp2006)


So..here's an attempt at answering the questions....

A. Person, Employee, HourlyEmployee and SalariedEmployee have the address variable

B. No

C. Um....building? I don't understand this question.

D. name, address, employeeID and weeklyPay

E. Employee, HourlyEmployee and SalariedEmployee

F. name and address

G. name, address, employeeID, and hourlyRate

H. address, hoursOpen and number

I. Employee, HourlyEmployee and SalariedEmployee

Does someone know if any of these are right? Comments would be helpful.

A) What about building?    :)
B) Correcto!
C) The answer is building. Take a look at the connecting lines... There's a relationship between office and building, and the building is known as 'building' to the office.
That't what those variables outside the boxes (on the lines) are... Thus, every building has something called 'offices' too... (don't know if it's a LL, array, or what.
D) And office. I'm pretty sure on this one. Again, there's a relationship with Office, via the variable 'office'
E) Yup
F) Yay
G) Yea
H) And building, I believe, for reasons stated above...
I) That's what I've got.
If I've got the 'building' and 'office' vars wrong, ie. they're not instance vars, please let me know... But I'm pretty sure they are.
~Jim

If Building has the address variable, would that mean that Office would as well? So 6 class instances know address(Person, Employee, SalariedEmployee, HourlyEmployee, Office and Building)

Nope. Office has a building. As opposed to employee is a person. The arrow with the triangle at the end indicates the inheritance, not a regular arrow, so office doesn't inherit address from building. And it makes sense logically, too. All offices have a building that they are in and all buildings have offices in them. But, all offices aren't buildings, and all buildings aren't offices. So, I'm stickin' to my guns.   :)
~Jim

now hold on a second–doesn't person have an address as well? it's listed second on the chart, right after name. so would then person, employee, S.Employee, H.Employee, and office all have "address"?

oh wait...first i mean building, not office, in that last message. secondly, i just realised jim was adding building to the existing list, rather than suggesting building was the only answer to part A :) nevermind. i misread. ignore the last message completely :P

So, an arrow just represents a connection between classes? So building can have an instance of office, but office is more of a seperate add-on than an extension of the class? The arrows lost me....

Y'all are really doing well at this! Yes – an open arrow is just a connection, just an "adding on to." A closed arrow is inheritance. Mark Guzdial

I think the answer to H is supposed to be number, building, and occupant. Does an Office really have an address and an hoursOpen also? Someone let me know if I'm wrong.

Nope, you're right. That's what I've got–It seems that your eyes are sharper than mine, as I failed to notice that the original answer didn't match mine...
H is number, building, and occupant. Good catch!
~Jim

I've been trying to make sense of the words next to a lot of the arrows. From what I understand:
A building can have an unlimited number if offices, but an office can only have one building.
An office can only have one person(occupant) and that person can only have one office.


Is this right? Can I apply the same logic to the other example as well?

Why does SalariedEmployee have office as an instance variable but not occupant?

:D     The gremlin in his head? Think about that question–why doesn't a salariedEmployee have an occupant... Who occupies you?   :)
But aside from common sense, office is over by Office and occupant is over by SalariedEmployee.
That means that Office is related to SalariedEmployee by the variable occupant and SalariedEmployee is related to Office by the variable office.
~Jim

According to the arrows:
Building gains the variable offices from Office.
Office gets the variable building from Building.
Office gets the variable occupant from SalariedEmployee.
SalariedEmployee gets the variable office from Office.

I'm trying to figure out the meanings of the words around the arrows. Help. Please.

Huh? Building and Office have no inheritance relationship. No variables are "gained" from them. An office has a variable that points to its building. A building has a bunch of offices (maybe as a linked list? maybe as an array?). Mark Guzdial