University of Southern California ISE 582: Web Technology for Industrial Engineering

advertisement
University of Southern California
Daniel J. Epstein Department of Industrial and Systems Engineering
ISE 582: Web Technology for Industrial Engineering
Midterm: Chase/Tovey’s Chickens
Instructor: Elaine Chew
Distributed 10pm, Wednesday, 22 Oct 2003
Due 10pm, Thursday, 23 Oct 2003
OPEN BOOK
NOTE: You are expected to complete the midterm on your own
without external help. Please review the Academic Integrity Policy
described on the course syllabus in case of doubt.
The following question is based on Ivan Chase and Craig Tovey’s chicken
dominance hierarchy research. Scientists have found that animals in groups tend to
form dominance hierarchies that are transitive and acyclic, meaning that, if A
dominates B, and B dominates C, then A dominates C. In an attempt to observe,
quantify and analyze the formation of dominance hierarchies, Tovey, studies the
behavior of chicken in pairwise confrontations. These observations are documented
in text files such as chicken.txt. Each text file documents the final pecking order
among four chickens and the details of each encounter as shown in “chicken.txt”. In
the text file,
J = jump
P = peck
I = inched away from
For example, 2J3 means that chicken 2 jumped on chicken 3; 1P3 means that chicken 1 pecked chic
Your task during the next 24 hours is to create a set of programs that read in and
store chicken data, analyze the data, and present the information using a “music
notation” chart, a Tovey invention. The following instructions will lead you through
this process.
[1] PHASE I: Read in chicken data from the file “chicken.txt” and store it in a vector.
(a)
First, create a class Encounter with the following attributes:
LeftChicken – identifier number for chicken left of action
RightChicken – identifiernumber for chicken right of action
Action – type of encounter (J,P or I)
[ 5 points ]
1
ISE 582: 2003: Midterm
http://www-classes.usc.edu/engr/ise/582
Also, include the following instance methods:
the usual get/set method
identifyDominantChicken()
displayEncounter()
(b)
[ 3 points ]
[ 10 points ]
[ 5 points ]
Create a class Hierarchy with the following attributes:
topChicken
secondChicken
thirdChicken
fourthChicken
Be sure to include appropriate get and set methods.
(c)
[10 points]
Next, create a ChickenData class with the following attributes:
chickenHierarchy – an instance of Hierarchy
chickenEncounters – a vector of encounters
Be sure to include the following instance methods:
get and set methods
[ 2 points ]
[15 points]
DisplayChickenData() – displays chicken information using an iterator
[10 points]
Enforce all requirements in parts (a) through (c) using an Interface classes.
[5 points]
2
import
ISE 582: 2003: Midterm
http://www-classes.usc.edu/engr/ise/582
[2] PHASE II: Create a window to represent the information using “music notation” (a Chase & Tove
Top Chicken
2nd Chicken
3rd Chicken
4th Chicken
In a Demonstrate class, create a window that displays the chicken dominance
hierarchy and encounters information using “music notation.” Be sure that:
(a)
you use the importChickenData to read in and store the chicken
information
[5 points]
(b)
the chickens are arranged hierarchically from top to bottom, with the top
chicken in the top row.
[10 points]
(c)
each arrow identifies the chickens engaged in an encounter, and the start
and end of each arrow identify the winner and loser in the encounter. Use
identifyDominantChicken to determine the direction of the arrow.
[ 20 points ]
[3] Contributed questions:
(a) What is the difference between a class variable and an instance variable?
Using an example in your code, explain why a class/instance variable was
used in that particular case.
[ 10 points ]
(b)
What is the difference between a class method and an instance method?
Using an example in your code, explain why a class/instance method was
used in that particular case.
[ 10 points ]
E.C. 22 October 2003
[ total: 120 points ]
3
Download