The Artima Developer Community
Sponsored Link

Java Answers Forum
basic help - getting 2 inputs

1 reply on 1 page. Most recent reply: Aug 20, 2003 1:58 AM by David

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Alex

Posts: 4
Nickname: alex107
Registered: Aug, 2003

basic help - getting 2 inputs Posted: Aug 19, 2003 9:38 PM
Reply to this message Reply
Advertisement
hi, i am creating this basic program/game. i need to get two inputs from the user. the problem is when i run the program it gets the first input from the user but then doesn't get the second input.. please help, the code is as follows:

public class game
{
public static void main(String[] args)
{
char rock = 'r';
char paper = 'p';
char sciccsors = 's';

do
{
System.out.println("Player 1 please enter a letter");
char c1 = SavitchIn.readChar();

System.out.println("Player 2 please enter a letter");
char c2 = SavitchIn.readChar();

winnercalculation(c1,c1);

game.winnercalculation(c1,c2);
} while (quitoption());

}

public static void winnercalculation(char c1, char c2)
{
char rock = 'r';
char paper = 'p';
char sciccsors = 's';

if ((c1 == rock) && (c2 == paper))
System.out.println("Player 2 Wins");
}

private static boolean quitoption()
{
System.out.print("Would you like to repeat this program?");
System.out.println(" (y for yes or n for no)");
char answer = SavitchIn.readLineNonwhiteChar();
return ((answer == 'y') || (answer == 'Y'));
}
}

thanks for your help
alex


David

Posts: 150
Nickname: archangel
Registered: Jul, 2003

Re: basic help - getting 2 inputs Posted: Aug 20, 2003 1:58 AM
Reply to this message Reply
We need to see the definition of:

SavitchIn.readChar();

Flat View: This topic has 1 reply on 1 page
Topic: ANT task Previous Topic   Next Topic Topic: Images in JComboBox

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use