Extension: Moody Finch
Would we rather create R2D2 or the Terminator? That’s the central question behind the notion of emotional robots – if we give our robots the ability to feel, they’re much less likely to annihilate the human race with nuclear weapons1 or to enslave us so that they can use us as batteries2.
Right now, the Finch doesn’t have any emotions, and a world dominated by small (but coldly brutal) USB-tethered robots is only a few iterations of Moore’s law away3. Save us all from this fate by giving Finch some emotions; you will create a new class, called MoodyFinch, which has an internal emotional state. This class should contain the following methods:
public boolean setEmotion(String setting) – Sets the internal emotion variable. Returns true if an acceptable emotion (angry, sad, happy, or blah) was used, false otherwise
public void playEmotion( ) – Plays the sequence of the current emotion
public String getEmotion( ) – Returns the Finch’s current emotional state
private void angry( ) – The Finch shows that it’s angry
private void happy( ) – The Finch runs a happy routine
private void sad( ) – The Finch runs a sad routine
private void blah( ) – The Finch should act apathetic and uncaring
The angry(), happy(), sad(), and blah() methods are private, and so can’t be called by any methods outside the MoodyFinch class. Instead, people using the MoodyFinch class will call playEmotion( ) to play whichever of these four routines the Finch is feeling right now. The routines should involve use of the beak LED and the motors. The Finch should say something or make a sound whenever one is called.
Remember that you will also need to write a client class to fully test the functionality of your MoodyFinch class.
1 See Terminator . And Battlestar Galactica (though arguably those robots had emotions, but they should’ve been programmed with happier ones)
2 See The Matrix
3 Moore’s Law