CSC 216 F09/ActionEvents

From Expertiza_Wiki
Revision as of 21:35, 11 November 2009 by Sdelliot (talk | contribs)
Jump to navigation Jump to search

Listen to this!

By, Steven Elliott, Eric Lumpkin, Ryan Orning

Purpose:

This game is intended to give beginning and intermediate java classes an opportunity to understand the concept behind action events in relation to GUI programming. This game is intended to be informative, interactive, and at the same time entertaining.

Supplies:

  • 6 willing participants
  • 3 pieces of paper with if/else statements that correspond to the button names. The inside should have some fun but not demeaning task. Use Pseudo-code.
// Hello World in Microsoft C# ("C-Sharp").

using System;

class HelloWorld
{
    public static int Main(String[] args)
    {
        Console.WriteLine("Hello, World!");
        return 0;
    }
}
 
     if(e.getSource() == btnJump) { 
             run(do 5 jumping jacks)
      }
  • 3 pieces of paper with the button names on them. Try to make them ambiguous so that the action performed does not know what the action will be.

Set up:

Have 3 of the volunteers be the buttons. Give each button a piece of paper with the button name on it. The buttons should NOT look at the paper. Then have your other 3 volunteers be the actionPerformed method. They should stand in order. With the else’s being after the first if statement. They CANNOT look at their action. This will be more entertaining for the class and also shows that the actionPerformed method is unaware of the task until it is activated.

Playing the Game:

Have the class “push” (pick) a button. The button then takes the paper with the name on it and hands it to the first if statement. The if/else’s should run as a normal program would and pass the paper to the next one until the action is carried out. Once the paper gets to the correct if statement, the action within the statement should be carried out. Then repeat until all the buttons/actions have been preformed.

Example actions:

  • Jumping jacks
  • Saying a phrase System.out.speak(“Java is my favorite language”);
  • Writing a phrase on the whiteboard.
  • Etc.