| Lab | Assigned | Design Due (In class) 10 AM |
Implement (In Lab) |
Demo (In Lab) |
Lab Due (In class) Friday 10 AM |
|||||
|---|---|---|---|---|---|---|---|---|---|---|
| 13 | Sep | None | 17-18 | Sep | 24-25 | Sep | 27 | Sep | ||
By the end of this lab you should:
Zip includes:
The
time has come for computers to show their inner emotions. As CS101 students, it is your job to implement an electronic emotion display, or Emote.
The Emote should
display the following:
Head, constructed from an Ellipse, and filled with a range of WebSafeColors that change to reflect the Emote's temperature in nine stages:Emote is hotEmote is neither hot nor cold.Emote is coldAny additional features or emotions will gain you favor with your TAs, and Extra Credit in CS101.
Emote, and the four arrow keys to change its emotions. The class that listens for key presses, EKeyListener.java, and all the necessary code are provided for you.Emote has-a:
Emote class. The Emote class controls the emotions and informs each of the Emote's features when a change in emotion occurs. An Emote has-aDrawingGrid, which enables relative placements on the DrawingPane.Slider, two of them, which keep track of the Emote's happiness and temperature
Head, which has-an EllipseMouth, which has-an ArcEyeComponents, each EyeComponent has-a:Eyebrow, which has-an ArcEmote's emotions: Emote.java.Emote acts as a control center, or the 'brain' of the program. It has access to both internal and graphical representations of of the program. Each Emote has two emotional Sliders, 'temperature' and 'happiness.'public Emote(int width, int height)public double getTemperature()Sliderpublic double getHappiness()Sliderpublic void adjustTemperature(double deltaT)Slider by the amount 'deltaT' and then calls updateFeatures().public void adjustHappiness(double deltaH)Slider by the amount 'deltaH' and then calls updateFeatures().public void setTemperature(double newValue)Slider to 'newValue.'public void setHappiness(double newValue)Slider to 'newValue.'public void updateFeatures()Slider has a minValue, a maxValue, and a curValue (current value). The current value is changed by mutators in Slider.java. You must ensure that curValue remains within minValue and maxValue.public Slider(String name, double min, double max, double startPoint)Slider based on the given specifications. The Slider has a value between the min and max values.public double getValue()Slider.public double getFraction()Slider. This is computed
as the Slider's (current value - min value) divided by the difference
between its max and its min.public void adjustValue(double deltaX)Slider by the specified 'deltaX.' If a change of 'deltaX' yields a curValue that is greater than maxValue, curValue should be set to maxValue. If a change in 'deltaX' yeilds a curValue that is less than minValue, curValue should be set to minValue.public void setValue(double newValue)Slider to be the 'newValue.' If the 'newValue' is either greater than the maxValue or less than the minValue, round to the appropriate value. (Hint: can you think of a helper method that might have a common utility to adjustValue(double deltaX) and setValue(double newValue)? )Ellipse on the Emote ViewFrame to represent the Emote's Head, and changes its color based on the 'temperature' Slider.public Head(int width, int height, Slider temperature, DrawingPane pane, DrawingGrid grid)Slider so the Head can update itself. You are provided with three WebSafeColors, a blue color for cold, an orange color for normal temperature, and a red color for hot. You will need to pick between these WebSafeColors based on the value of the Emote's 'temperature' and then call saturate() in order to obtain the appropriate intensities of these colors. For the sake of appearance, you might also want to add a nose in this class (using an Arc).public void update()Slider.Slider.public Mouth(int width, int height, Slider happiness, DrawingPane
pane, DrawingGrid grid)
public void update()Sliderpublic Eyebrow(int width, int height, Slider happiness, DrawingPane
pane, DrawingGrid grid)Slider. Also, you might want to create your eyes in this class. Since the eyes do not change with the Emote's emotions, you can make them as detailed (or spartan) as you see fit.public void update()Slider.
Emote.
Note that your Emote does not need to look exactly like the class solution . You will get full credit even if your Emote (for example, its eyes) is not as attractive as ours. You can earn extra credit by having Emote be more expressive than ours, however. Ask the TAs about this.
Here is a suggested implementation:
Slider and briefly test each of its methods.Emote class. Create two sliders for 'happiness' and 'temperature'. Remember that Emote is the emotional control for all of an Emote's features. Once Emote's methods are correctly completed, EKeyListener will be functional.
Emote for you and
put it in a ViewFrame.update() method in this class changes the color of the Emote's head based on the value of the 'temperature' Slider. You must have 9 different colors for the different values of the 'temperature' Slider.
Emote, position and add the mouth.
Emote and Mouth correctly, you should be able to use EKeyListener to help you test your code.EyeComponent, and give the eye an Eyebrow. Remember, EyeComponent is a container for the graphical eye and the Eyebrow. The Emote will only know about the EyeComponent, which will in turn have a notion of its Eyebrow. (Confused yet? Ask if you need clarification.) Again, return to Emote to add two EyeComponents.