here's the actual code
import java.io.*;
import java.lang.*;
public class RandomStuff
{
public static void main (String[] args) throws IOException
{
try{
System.out.println ("Thomas Boeckman \n Program #1: charachter game \n RRHS Java class");
playGame();
}
catch (NullPointerException e)
{
System.out.println ("ATTENTION: Under normal circumstances, this error would have gone through. However, attention to detail as been paid and this error now is invalid.");
playGame();
}
}
public static void playGame() throws IOException
{
try{
String Yorn;
BufferedReader keyboard;
boolean loopNeeded;
keyboard = new BufferedReader(new InputStreamReader(System.in));
System.out.println ("Would you like to play the game? \n Type Y or N and press Enter");
Yorn = keyboard.readLine();
if (Yorn.equalsIgnoreCase("y"))
enterChar();
else if (Yorn.equalsIgnoreCase("n"))
System.exit(1);
else
{
System.out.println ("Follow Directions!");
playGame();
}
}
catch (NullPointerException e)
{
System.out.println ("ATTENTION: Under normal circumstances, this error would have gone through. However, attention to detail as been paid and this error now is invalid.");
playGame();
}
}
public static void enterChar() throws IOException
{
try{
String letter;
BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
char x,y,z;
final String consonant = "qwrtypsdfghjklzxcvbnm";
final String vowel = "aeuio";
System.out.println ("Enter one letter from A to Z and press Enter");
letter = keyboard.readLine();
x = letter.charAt(0);
for (int t=0; t < 26; t++)
{
y = vowel.charAt (t);
z = consonant.charAt (t);
if (x == z)
{
System.out.println ("You entered a consonant!");
playGame();
}
else if (x == y)
{
System.out.println ("You entered a vowel!");
playGame();
}
else
{
System.out.println ("Follow directions!");
enterChar();
}
}
}
catch (NullPointerException e)
{
System.out.println ("ATTENTION: Under normal circumstances, this error would have gone through. However, attention to detail as been paid and this error now is invalid.");
playGame();
}
}
}
This post has been edited by jayman9: 07 December 2006 - 10:08 PM

New Topic/Question
Reply



MultiQuote





|