pinkkop
09-30-2006, 05:16 PM
sorry about the other post
can anyone help me out with this
thanks
i am trying to get it to play again and not print out the scores until the player is done playing
import java.util.Scanner;
import java.util.Random;
public class boobitty
{
public static void main (String[] args)
{
int Computer=0,Player=0,tie=0,compic,pscore;
String str="Y";
Random generate= new Random();
Scanner scan=new Scanner(System.in);
while (str=="Y");
{
compic=generate.nextInt(3)+1;
System.out.println ("Enter 1 for Rock, 2 for Paper, and 3 for Scissors");
pscore=scan.nextInt();
if (compic==pscore)
{
System.out.println("Tie Game");
tie++;
System.out.println ("Play Again? y/n");
str = scan.nextLine();
}
else
{
switch (pscore)
{
case 1:
{
if (compic==2)
{
System.out.println ("Paper beats Rock");
System.out.println ("Computer wins");
Computer++;
System.out.println ("Play Again? y/n");
str = scan.nextLine();
}
else
{
System.out.println ("Rock beats Scissors");
System.out.println ("Player wins!");
Player++;
System.out.println ("Play Again? y/n?");
str = scan.nextLine();
}
break;
}
case 2:
{
if (compic==1)
{
System.out.println ("Paper beats Rock");
System.out.println ("Player wins!");
Player++;
System.out.println ("Play Again? y/n?");
str = scan.nextLine();
}
else
{
System.out.println ("Scissors beat Paper");
System.out.println ("Computer wins!");
Computer++;
System.out.println ("Play Again? y/n?");
str = scan.nextLine();
}
break;
}
case 3:
{
if (compic==1)
{
System.out.println ("Rock beats Scissors");
System.out.println ("Computer wins");
Computer++;
System.out.println ("Play Again? y/n?");
str = scan.nextLine();
}
else
{
System.out.println ("Scissors beat Paper");
System.out.println ("Player wins");
Player++;
System.out.println ("Play Again? y/n");
str = scan.nextLine();
}
break;
}
default:
{
System.out.println("Enter 1 2 or 3");
System.out.println ("Would you like to play again? y/n");
str=scan.nextLine();
break;
}
}
}
}
if (str=="Y")
{
System.out.println ("Play Again? y/n");
str = scan.nextLine();
}
else
{
System.out.println ("Scores:");
System.out.println ("Ties= "+tie+" Wins= "+Player+" Losses= "+Computer);
}
}
}
this is what i get from it
Enter 1 for Rock, 2 for Paper, and 3 for Scissors
2
Scissors beat Paper
Computer wins!
Play Again? y/n?
Scores:
Ties= 0 Wins= 0 Losses= 1
can anyone help me out with this
thanks
i am trying to get it to play again and not print out the scores until the player is done playing
import java.util.Scanner;
import java.util.Random;
public class boobitty
{
public static void main (String[] args)
{
int Computer=0,Player=0,tie=0,compic,pscore;
String str="Y";
Random generate= new Random();
Scanner scan=new Scanner(System.in);
while (str=="Y");
{
compic=generate.nextInt(3)+1;
System.out.println ("Enter 1 for Rock, 2 for Paper, and 3 for Scissors");
pscore=scan.nextInt();
if (compic==pscore)
{
System.out.println("Tie Game");
tie++;
System.out.println ("Play Again? y/n");
str = scan.nextLine();
}
else
{
switch (pscore)
{
case 1:
{
if (compic==2)
{
System.out.println ("Paper beats Rock");
System.out.println ("Computer wins");
Computer++;
System.out.println ("Play Again? y/n");
str = scan.nextLine();
}
else
{
System.out.println ("Rock beats Scissors");
System.out.println ("Player wins!");
Player++;
System.out.println ("Play Again? y/n?");
str = scan.nextLine();
}
break;
}
case 2:
{
if (compic==1)
{
System.out.println ("Paper beats Rock");
System.out.println ("Player wins!");
Player++;
System.out.println ("Play Again? y/n?");
str = scan.nextLine();
}
else
{
System.out.println ("Scissors beat Paper");
System.out.println ("Computer wins!");
Computer++;
System.out.println ("Play Again? y/n?");
str = scan.nextLine();
}
break;
}
case 3:
{
if (compic==1)
{
System.out.println ("Rock beats Scissors");
System.out.println ("Computer wins");
Computer++;
System.out.println ("Play Again? y/n?");
str = scan.nextLine();
}
else
{
System.out.println ("Scissors beat Paper");
System.out.println ("Player wins");
Player++;
System.out.println ("Play Again? y/n");
str = scan.nextLine();
}
break;
}
default:
{
System.out.println("Enter 1 2 or 3");
System.out.println ("Would you like to play again? y/n");
str=scan.nextLine();
break;
}
}
}
}
if (str=="Y")
{
System.out.println ("Play Again? y/n");
str = scan.nextLine();
}
else
{
System.out.println ("Scores:");
System.out.println ("Ties= "+tie+" Wins= "+Player+" Losses= "+Computer);
}
}
}
this is what i get from it
Enter 1 for Rock, 2 for Paper, and 3 for Scissors
2
Scissors beat Paper
Computer wins!
Play Again? y/n?
Scores:
Ties= 0 Wins= 0 Losses= 1