CSC 216/s08/youthful aspirations

From Expertiza_Wiki
Jump to navigation Jump to search

Formatting Resources

Formatting Help Guide from MetaWiki

Mad Libs(For J2SE Students)

The problem: Java lectures tend to be boring.

Basically no matter what you do when lecturing to students, their attention spans are going to be fairly limited and within 30s-40s they are no longer paying attention. Inherently, these poor, utterly useless souls will only respond when they hear cues of awkward silence or mass confusion. Our idea is to force student participation via electro-shock therapy... or whimsical humor; which ever is the easiest to implement.

Participants and props

All students are capable of participating... they simply will shout out what they would like to see written on the board.

Props

  • Projector / Screen that is large enough for all students to view the source code on the screen.
  • Laptop / Desktop to project the code and options.
    • Operating system with presentation software.
    • Presentation software.
    • Source code relevant to the lesson you are teaching.

The Game

Very similar to how the original Mad Libs game was done, you first examine the source code you plan to work with.


       public class myfirstjavaprog
       {  
               public static void main(String args[])
               {
                  System.out.println("Hello World!");
               }
}

Now you will pull out the key elements to the program which are:

  • Class Name
  • String to be displayed


At this point you will display to your students the choices they can name and wait for them to shout out answers. For this demo let us say Cocaine and Charlie Murphy. So:

  • Class Name = Cocaine
  • String = Charlie Murphy

Now you will put these into the source code on screen making it look like this:

       public class Cocaine
       {  
               public static void main(String args[])
               {
                  System.out.println("Charlie Murphy");
               }
}

Next you can compile the code on screen and show the relation between the content they generated and how it modifies the code and its output.

Examples

Chris likes older women

1.

 public account create_account(double balance)
   {
      account my_account;
 
      // Instantiate a new object
      my_account = new account(balance);
 
      // Call the deposit method of our object my_account
      my_account.deposit(25.00);
   
      return account;
   }

Will then have the following modifiers:

  • Return Type: account
  • Method Name: create_account
  • First variable Name: account
  • Double Value: balance
  • New Object: my_account

The class should then shout out a few like these:

  • Return Type: Kevin-Bacon
  • Method Name: Notepad
  • First variable Name:Cheese
  • Double Value:Corkscrew
  • New Object: tesla_clone


The Source code after this is:

 public Kevin-Bacon Notepad(double corkscrew)
   {
      notepad cheese;
 
      // Instantiate a new object
      cheese = new Kevin-bacon(corkscrew);
 
      // Call the deposit method of our object my_account
      my_account.deposit(25.00);
   
      return account;
   }