CSC 216 F09/ActionEvents: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 12: Line 12:
* 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.
* 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.


<source lang="csharp">
<syntaxhighlight lang="csharp">
// Hello World in Microsoft C# ("C-Sharp").
// Hello World in Microsoft C# ("C-Sharp").


Line 25: Line 25:
     }
     }
}
}
</source>
</syntaxhighlight>


<source lang="java5">  
<source lang="java5">  

Revision as of 21:36, 11 November 2009

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.