CSC 216/s08/youthful aspirations: Difference between revisions
(15 intermediate revisions by 3 users not shown) | |||
Line 7: | Line 7: | ||
===The problem: Java lectures tend to be boring.=== | ===The problem: Java lectures tend to be boring.=== | ||
Basically no matter what you do | Basically no matter what you do when lecturing 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=== | ===Participants and props=== | ||
Line 13: | Line 13: | ||
==Props== | ==Props== | ||
*Projector / | *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. | *Laptop / Desktop to project the code and options. | ||
**Operating system with presentation software. | **Operating system with presentation software. | ||
Line 21: | Line 21: | ||
===The Game=== | ===The Game=== | ||
Very similar to how the original Mad Libs game | Very similar to how the original Mad Libs game was done, you first examine the source code you plan to work with.<br/> | ||
<tt> | |||
<code><pre> | |||
public class myfirstjavaprog | |||
{ | |||
public static void main(String args[]) | |||
{ | |||
System.out.println("Hello World!"); | |||
}<br/> | |||
} | |||
< | </pre></code> | ||
</tt> | </tt> | ||
Line 39: | Line 41: | ||
<br/> | <br/> | ||
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: | 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 | *Class Name = Cocaine | ||
*String = Charlie Murphy<br/> | *String = Charlie Murphy<br/> | ||
Line 45: | Line 47: | ||
Now you will put these into the source code on screen making it look like this: | Now you will put these into the source code on screen making it look like this: | ||
<tt> | <tt> | ||
<code><pre> | |||
public class Cocaine | |||
{ | |||
public static void main(String args[]) | |||
{ | |||
System.out.println("Charlie Murphy"); | |||
}<br/> | |||
} | |||
</pre></code> | |||
</tt> | |||
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== | |||
=1.= | |||
<tt> | |||
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; | |||
} | |||
</tt> | |||
Will then have the following modifiers: | |||
*Return Type: account | |||
*Method Name: create_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 | |||
*Double Value: Cheese | |||
*New Object: Corkscrew | |||
<br/> | |||
The Source code after this is: | |||
<tt> | |||
public Kevin-Bacon notepad(double cheese) | |||
{ | |||
Kevin-Bacon corkscrew; | |||
// Instantiate a new object | |||
corkscrew = new Kevin-Bacon(cheese); | |||
// Call the deposit method of our object my_account | |||
corkscrew.deposit(25.00); | |||
return Kevin-Bacon; | |||
} | |||
</tt> | </tt> | ||
=2= | |||
<code><pre> | |||
import java.util.Scanner; | |||
public class Addition | |||
{ | |||
/** | |||
*This method is the main one and recieves the integers then adds them, the sum is then output to the screen. | |||
*@param args | |||
*/ | |||
public static void main(String[] args) | |||
{ | |||
Scanner scan = new | |||
Scanner(System.in); | |||
System.out.println("Please enter an integer"); | |||
int a = scan.nextInt(); | |||
System.out.println("Please enter a new integer"); | |||
int b = scan.nextInt(); | |||
System.out.println("The sum of the two integers is " + (a + b)); | |||
} | |||
} | |||
</pre></code> | |||
Values to change: | |||
*Class Name: Addition | |||
*Variable 1: scan | |||
*String 1: Please enter an integer | |||
*Variable 2: a | |||
*String 2: Please enter a new integer | |||
*Variable 3: b | |||
*String 3: The sum of the two integers is | |||
<br/> | |||
New Values: | |||
*Class Name: Hippo | |||
*Variable 1: mouse | |||
*String 1: Its not what you did, its who saw. | |||
*Variable 2: LOL_Cat | |||
*String 2: Until victory always. | |||
*Variable 3: Hai_Guys | |||
*String 3: One should always play fairly when one has the winning cards. | |||
<br/> | |||
New Code: | |||
<code><pre> | |||
import java.util.Scanner; | |||
public class Hippo | |||
{ | |||
/** | |||
*This method is the main one and recieves the integers then adds them, the sum is then output to the screen. | |||
*@param args | |||
*/ | |||
public static void main(String[] args) | |||
{ | |||
Scanner mouse = new | |||
Scanner(System.in); | |||
System.out.println("Its not what you did, its who saw."); | |||
int LOL_Cat = mouse.nextInt(); | |||
System.out.println("Until victory always."); | |||
int Hai_Guys = mouse.nextInt(); | |||
System.out.println("One should always play fairly when one has the winning cards. " + (LOL_Cat + b)); | |||
} | |||
} | |||
</pre></code> |
Latest revision as of 21:00, 26 March 2008
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 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!");
}<br/>
}
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");
}<br/>
}
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
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
- Double Value: balance
- New Object: my_account
The class should then shout out a few like these:
- Return Type: Kevin-Bacon
- Method Name: Notepad
- Double Value: Cheese
- New Object: Corkscrew
The Source code after this is:
public Kevin-Bacon notepad(double cheese) { Kevin-Bacon corkscrew; // Instantiate a new object corkscrew = new Kevin-Bacon(cheese); // Call the deposit method of our object my_account corkscrew.deposit(25.00); return Kevin-Bacon; }
2
import java.util.Scanner;
public class Addition
{
/**
*This method is the main one and recieves the integers then adds them, the sum is then output to the screen.
*@param args
*/
public static void main(String[] args)
{
Scanner scan = new
Scanner(System.in);
System.out.println("Please enter an integer");
int a = scan.nextInt();
System.out.println("Please enter a new integer");
int b = scan.nextInt();
System.out.println("The sum of the two integers is " + (a + b));
}
}
Values to change:
- Class Name: Addition
- Variable 1: scan
- String 1: Please enter an integer
- Variable 2: a
- String 2: Please enter a new integer
- Variable 3: b
- String 3: The sum of the two integers is
New Values:
- Class Name: Hippo
- Variable 1: mouse
- String 1: Its not what you did, its who saw.
- Variable 2: LOL_Cat
- String 2: Until victory always.
- Variable 3: Hai_Guys
- String 3: One should always play fairly when one has the winning cards.
New Code:
import java.util.Scanner;
public class Hippo
{
/**
*This method is the main one and recieves the integers then adds them, the sum is then output to the screen.
*@param args
*/
public static void main(String[] args)
{
Scanner mouse = new
Scanner(System.in);
System.out.println("Its not what you did, its who saw.");
int LOL_Cat = mouse.nextInt();
System.out.println("Until victory always.");
int Hai_Guys = mouse.nextInt();
System.out.println("One should always play fairly when one has the winning cards. " + (LOL_Cat + b));
}
}