Thursday, September 23, 2010

Input

Here is a helper class that I created for getting input from the console in java. Created a java class named InputHelper and paste the content below and press ctrl+shift+f to format it.

Friday, August 13, 2010

Creating and Generating Java Doc

To generate java docs in code simply type "/**" and press enter. The first sentence you write is the summary and the rest in put in the details section.
Here is an example: (Unfortunately I couldn't format the code on here, sorry)
/**
* Get's the input from the user as a short. The input must be between the lower and
* upper bounds specified inclusive. If not between the values the user will be prompted
* with the error "Please input a number between (lower) and (upper) inclusive." The user
* will continue to be prompted with the message to display until valid input is given.
*
* @param lower bound
* @param upper bound
* @param display what to prompt the user before accepting input
* @return input from the user as a short
*/
public static short getShort(short lower, short upper, String display){
boolean valid = false; short result = 0;

while(!valid){ System.out.print(display);
String input = getString();
if(isWholeNumber(input)){
result = Short.parseShort(input);
valid = withinBounds(lower, upper, result);
}
}

return result;
}
To generate the html for the javadoc, right click on the project and select export. Type javadoc in the window as shown below and select javadoc.

Once your done specify the location of the javadoc tool. For me the path is "C:/Program Files/Java/jdk1.6.0_20/bin/javadoc.exe " As shown below.


Press finish and voila, your done generating javadocs.