Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: switch Example - Random Insults

The following class could be useful for generating random insults in response to erroneous user input.

Tutorial Details:

The following class could be useful for generating random insults in response to erroneous user input.

Formatting. Some of the cases are formatted on a single line. This is a common style when they do similar short actions. It makes the switch statements much easier to read.

Arrays? This version is written without using arrays, which would provide a better way to do this.

Overloading rand(). The rand() method is overloaded only to demonstrate this feature.

Separate logic from user interface. This program is separated into two files: one file contains the logic for generating the insult in a string. It knows nothing about the user interface, and could equally well be used in a dialog program (as in the test program below), console I/O, a GUI program, or a web-based application.


 

Rate Tutorial:
http://www.roseindia.net/java/java-tips/flow/switch/switch-ex-insults.shtml

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
switch Example - Random Insults

View Tutorial:
switch Example - Random Insults

Related Tutorials:

Java decompilers compared - JavaWorld - July 1997
Java decompilers compared - JavaWorld - July 1997
 
Java Tip 68: Learn how to implement the Command pattern in Java - JavaWorld - February 1999
Java Tip 68: Learn how to implement the Command pattern in Java - JavaWorld - February 1999
 
Programming Java threads in the real world, Part 5 - JavaWorld - February 1999
Programming Java threads in the real world, Part 5 - JavaWorld - February 1999
 
A promise of easier embedded-systems networking - JavaWorld November 1999
A promise of easier embedded-systems networking - JavaWorld November 1999
 
Device programming with MIDP, Part 2 - JavaWorld March 2001
Device programming with MIDP, Part 2 - JavaWorld March 2001
 
J2SE 1.4 premieres Java's assertion capabilities, Part 1
J2SE 1.4 premieres Java's assertion capabilities, Part 1
 
Integrate EJBs with CORBA
Integrate EJBs with CORBA
 
Evolve your apps with the Phased Process pattern
Evolve your apps with the Phased Process pattern
 
JavaWorld article
JavaWorld article
 
Build an interpreter in Java -- Implement the execution engine (JavaWorld / July 1997 / by Chuck McManis)
Build an interpreter in Java -- Implement the execution engine (JavaWorld / July 1997 / by Chuck McManis)
 
Best tools for mobile application development
Best tools for mobile application development
 
roots of constants classes
roots of constants classes
 
JavaServer Faces, redux
JavaServer Faces, redux
 
Interesting ...
Interesting ...
 
Wakeonlan
What is wakeonlan? wakeonlan is a small OS independent java program that sends 'magic packets' to wake-on-lan enabled ethernet adapters and motherboards in order to switch on the called machine.It runs on every machine with an installed 1.4 java runtime.
 
JSyntaxColor 1.2.7
JSyntaxColor 1.2.7 JSyntaxColor is a library for coloring in real time user text input.
 
Networking our whiteboard with servlets.
Find out how to easily replace the RMI and sockets networking layers with servlets.
 
Migrating from Windows to Linux, Part 1: Preparation
Want to switch to Linux, but don't know where to begin? In Part I of Migrating from Windows to Linux, THG will help you prepare for the big move. Step-by-step instructions and printable checklists will ensure your happy and safe journey into Linux.
 
SSH Port Forwarding Through a Proxy Server (Community-Submitted Tech Tip)
Learn how to use SSH port forwarding (tunneling) through a proxy server for secure connections.
 
Easy Emulation With New NetBeans Mobility Pack 4.0
With the click of a button, switch back and forth between different emulation environments while developing one set of code. It's never been this easy to take advantage of Java technology's cross-platform capabilities.
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.