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

Lab3 - Sp2000

Lab 3

The Situation

The citizens of Yakashaw, Alabama are aputtin' on another hoedown tonight. Spirits will be high, the spirits will be flowing, the music will be thumping, and the square
dancing will be wild beyond your belief. To get things rolling, everyone says hello....

Now, the people of Yakashaw are polite folk with real good upbringing. When a Yakashaw gentleman greets someone or is greeted, he not only says hello but he also bows.
And when a Yakashaw lady greets someone or is greeted, she not only says hello but she also curtsies. Assuming, of course, that the person being greeted isn't at feud with
the person doing the greeting. In that case, the greetee replies with a rude sniff and turns their back–about as rude as it gets in Yakashaw! (truly angry Yakashawians
sometimes resort to yo-mama jokes, but this is rare). Thankfully, all Yakashawians are very polite, and they save the bloodletting until after the hoedown.


The goal of the lab is to model what happens when one person at the hoedown greets another. Now, you've already seen in a previous lab what happens when one Muppet
greets another–they just say their bit and go on. However, Yakashaws are more complex; polite folk that they are, they actually respond to a greeting. If the person who
greeted them deserves it, of course.

The class candidates that come first to come to mind are Person, Gentleman, and Lady. Looking through the description for other nouns, the candidates Yakashaw (the
town), Hoedown, and Family seem like reasonable classes. Now let's refine this.

First, should Gentleman and Lady be subclasses of Person, or should there just be an attribute in Person to make the distinction? Well, for our purposes, the only difference
is that they have different greeting behavior (bowing versus curtsying). Furthermore, a given instance will never change from being a Gentleman to a Lady nor vice versa.
From these considerations, making them separate classes seems like a good way to go; we'll stick with that unless another consideration comes to mind.

Okay, well how should feud's be represented? We are going to need a way to ask questions like "Is Joe's family feuding with Sarah's family". So we need to represent which
families are feuding with which... and that's about all our system needs to know about feuds. To simplify, we will even assume that each family is feuding with at most one
other family (Anything more and we would have to start thinking about collections again)

So how should this be done? Maybe each Person should have a feudingWith attribute which says what family they are feuding with. Then, each Person also can have a
family attribute which says what family they are in. To check whether two people are feuding, check one of their feudingWith attributes and see if it matches the other's
family attribute.

That would work, but that seems a little repetetive. Since every member of a given family should be feuding with the same other family, the feuding information isn't really
specific to a Person, but to a Family. So let's put the feudingWith attribute in Family instances instead of Person instances; a person can still decide who they are at feud
with by querying the family they are a member of. We have already decided to give a family attribute to Persons, so we're set.

The above covers pretty much all the basic functionality. We are left with the following classes:





We have found no use for the following classes:


Now we go back and fill in much more detail for the classes and methods in our system.

You may notice there is no way for a family to know what its members are. Given a Person, you can figure out what Family they are in, but not vice versa. This functionality is not required, obvious though it may be, so it can be safely left unimplebented. (and it simplifies the code!)


This is your part! Most of the details of the system have been laid out above. You need to create a new category, add the four classes (being careful about subclasses and
superclasses), and implement all the specified methods. Also, you will need to implement initialization methods not mentioned above: name:, family:, and feudingWith:.


When you're done, try the following code:
"create families"
macyntire := Family new.  macyntire name: 'Macyntire'.
macynzie := Family new.  macynzie name: 'Macynzie'.
jones := Family new.  jones name: 'Jones'.
smith := Family new.  smith name: 'Smith'.
elphen := Family new name: 'Elphen'.

"set up feuds"
macyntire feudingWith: macynzie.
macynzie feudingWith: macyntire.
smith feudingWith: jones.  
jones feudingWith: smith.

"create people"
billyBob := Gentleman new.  billyBob name: 'Billy Bob'.  billyBob family: 
billyJo := Lady new.  billyJo name: 'Billy Jo'.  billyJo family: macynzie.
bubba := Gentleman new.  bubba name: 'Bubba'.  bubba family: jones.
jane := Lady new.  jane name: 'Jane'.  jane family: smith.
lauralanthala := Lady new.  lauralanthala name: 'Lauralanthala'.  
lauralanthala family: elphen.

"do some greetings"
billyBob greet: billyJo.  Transcript cr.
billyJo greet: billyBob. Transcript cr.
bubba greet: jane.  Transcript cr.
jane greet: bubba.  Transcript cr.
billyBob greet: bubba.  Transcript cr.
jane greet: billyJo.  Transcript cr.
bubba greet: lauralanthala.  Transcript cr.
lauralanthala greet: bubba.   Transcript cr. 

It should give the following output:

Billy Bob says, "Salutations, Billy Jo"
Billy Bob bows.
Billy Jo sniffs and turns away.

Billy Jo says, "Salutations, Billy Bob"
Billy Jo curtsies.
Billy Bob sniffs and turns away.

Bubba says, "Salutations, Jane"
Bubba bows.
Jane sniffs and turns away.

Jane says, "Salutations, Bubba"
Jane curtsies.
Bubba sniffs and turns away.

Billy Bob says, "Salutations, Bubba"
Billy Bob bows.
Bubba bows.
Bubba says, "Greetings, Billy Bob.  A most exquisite evening for a 
hoedown, is it not?"

Jane says, "Salutations, Billy Jo"
Jane curtsies.
Billy Jo says, "Hi, Jane!"
Billy Jo curtsies.

Bubba says, "Salutations, Lauralanthala"
Bubba bows.
Lauralanthala says, "Hi, Bubba!"
Lauralanthala curtsies.

Lauralanthala says, "Salutations, Bubba"
Lauralanthala curtsies.
Bubba bows.
Bubba says, "Greetings, Lauralanthala.  A most exquisite evening for a 
hoedown, is it not?" 


Follow the posted turn in instructions.

Link to this Page