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

Lab 4 - Spring 2001 (Due 2/14/2001)

The purpose of this lab is to continue and expand on a previous real world design and implement a solution in Squeak.
Major Focuses:


THIS IS AN INDIVIDUAL LAB!
There are three main things to keep in mind while completing this lab:
1.  Correctly implement a solution to the stated problem,
2.  You will be emailed a zip file containing another student's Lab3 submission. Only working submissions will be distributed. You must use this BatBox implementation so either remove your submission from your image - or grab a new image and fileIn the new file.
3.  Write clear, readable, modifiable, and maintainable code


Project Description:

Real World Scenario: Boxstreet Bats


The Boxstreet Bats are a famous Bat-Band pop group. Their sultry style and dashing good looks woo many female teen-bats with songs like Ill Never Bite Your Neck, Show Me The Meaning of Being Nocturnal, and The Sonar. The Boxstreet Bats consists of five different types of bats: the heartthrob fruit bat, the rebel vampire bat, the cutie spotted bat, the shy brown bat, and the older brother gray bat. Currently they are in their sold-out world tour, going from city to city and wooing their audiences. However for today for some unbeknownst reasons (rumors of a conflict arising from the cutie spotted bat badgering a fan that shouted the heartthrob is cuter), three members of the Boxstreet Bats (the Vampire Bat, the Brown Bat, and the Gray Bat) decide to find bat boxes to sleep on their own for the night. Each of the different bat types has their own preference of bat box styles. It is your job to help determine the bat boxes that are acceptable to the bats.

In the previous lab, you were asked to write a bat box class. In this lab, you are to write bat classes that are to understand and use a bat box class written by a fellow classmate. The bat classes should be able inspect an instance of bat box and determine whether it will want to stay in the bat boxes. If the bat type does not like the bat box that its inspecting, then it should exhibit some sort of behavior to signify the rejection of the bat box. If the bat type does like the bat box that its inspecting, then it should exhibit some sort of behavior to signify the acceptance of the bat box. Although there are different species of bats, they are still similar to one another in some ways. So in this lab, we want you to create the bats using inheritance.

The different bat classes you need to create are AbstractBat, VampireBat, BrownBat, and GrayBat.

AbstractBat is the Bat that defines the behavior of all the bats. The AbstractBat have attributes (aka variables) of:

1. name - the name of the bat
2. batbox the batbox instance that its currently inspecting

The AbstractBat have the messages (aka methods) of:

1. name returns the name of the bat
2. name: - sets the name of the bat
3. batType returns the type of the bat
4. minHeight returns the minimum height of a bat box that it likes. Let the subclasses hand this
5. minWidth returns the minimum width of a bat box that it likes. Let the subclasses handle this
6. minPartitions returns the minimum width of a bat box that it likes. Let the subclasses handle this
7. lookAtBatBox: sets the bat box being passed in to the batbox variable
8. checkBatBoxSpecs tests to see if the batbox is acceptable to this bat type based on the minHeight, minWidth, and minPartitions, if so: return true, if false: return false.
9. testBatBox if checkBatBoxSpecs returns true, call acceptBatBox, if returns false, call rejectBatBox
10. acceptMessage returns the text for acceptMessage. Let the subclass handle this
11. rejectMessage returns the text for rejectMessage. Let the subclass handle this
12. acceptBatBox behavior for accepting a bat box. Let the subclasses handle this
13. rejectBatBox behavior for reject a bat box. Let the subclasses handle this
14. printString returns My name is [insert name] and I am an [insert batType] in a string.

The VampireBat is a subclass of the AbstractBat class and it likes bat boxes that adhere to the minimum specs of a good bat box:

1. Minimum height should be 24 inches
2. Minimum width should be 14 inches
3. Minimum number of partitions should be 1

For the methods that the VampireBat needs to define, the behaviors are:

1. The messages of minHeight, minWidth, and minPartitions should return the proper values
2. The message of acceptMessage should returns This bat box is cool
3. The message of rejectMessage should returns This bat box is not cool
4. The acceptBatBox message should print out the acceptMessage to the transcript.
5. The rejectBatBox message should print out the rejectMessage to the transcript.

The BrownBat is a subclass of the AbstractBat class and it likes bat boxes that adhere to these specs:

1. Minimum height should be 30 inches
2. Minimum width should be 20 inches
3. Minimum number of partitions should be 3

For the methods that the BrownBat needs to define, the behaviors are:

1. The messages of minHeight, minWidth, and minPartitions should reflect the specs
2. The message of acceptMessage should return I like this bat box
3. The message of rejectMessage should return I do not like this bat box
4. The acceptBatBox message should graphically indicate the bat's acceptance of the box using the drawing messages implemented in BatBox. In addition to displaying the acceptMessage somewhere on the screen nearby.
5. The rejectBatBox message should graphically indicate the bat's rejection of the box using the drawing messages implemented in BatBox. In addition to displaying the acceptMessage somewhere on the screen nearby.

The GrayBat is a subclass of BrownBat and it likes the same things for a bat box like the BrownBat except that:

1. It likes the minimum partition to be 5
2. It likes the color of the bat box to be blue

For the methods that the GrayBat needs to define, the additional behaviors are:

1. A message called colorMatch to return the proper color
2. The checkBatBoxSpecs message looks for a good bat box based on the height, width, number of partitions of the bat box, AND color.
3. The message of acceptMessage should return I love this bat box
4. The message of rejectMessage should return I despise this bat box
5. The acceptBatBox message should graphically indicate the bat's acceptance of the box using the drawing messages implemented in BatBox. In addition to displaying the acceptMessage somewhere on the screen nearby.
6. The rejectBatBox message should graphically indicate the bat's rejection of the box using the drawing messages implemented in BatBox. In addition to displaying the acceptMessage somewhere on the screen nearby.

So for the lab, you should be able to create instances of VampireBat, BrownBat, and GrayBat. With those instances, you should be able to pass in instances of the bat box class and test to see whether or not if the bat box is suitable for the bat instance. For example in your workspace, you can do:

batbox aj kevin howie

batbox1 := BatBox new; batbox height: 40; width: 50; partitions: 4; color: (Color blue).

aj := VampireBat new.
aj lookAtBatBox: batbox. aj testBatBox. should like the bat box, printing to transcript

howie := BrownBat new.
howie lookAtBatBox: batbox. howie testBatBox. should like the bat box, drawing picture indication acceptance

kevin := GrayBat new.
kevin lookAtBatBox: batbox. kevin testBatBox. should not like the bat box, drawing picture indicating rejection

Notes:

User Requirements:

Grading Criteria


What you should turn in: Spring 2001 Turnin Information
1. Your code: l4.st
2. IMPORTANT: You must provide a thorough README file that will describe how your program works, what it does, how to test and run it. We will reserve the right for TA to give you a ZERO if you did not explain how to run and test your code. Someone else, who never saw your code, should be able to understand/run/reuse your code after reading your README file.

Link to this Page