// The "FriedmanRPSgame" class.
import java.awt.*;
import hsa.Console;
public class FriedmanRPSgame
{
static Console c; // The output console
public static void main (String[] args)
{
c = new Console ();
// VARIABLES
int rock;
int paper;
int scissors;
// INPUT
c.println (" Choose 1 for rock, 2 for paper, 3 for scissors");
int choice =c.readInt();
int computer = Math.floor((Math.random()*3)+1);
if (Computer == 1 && choice == 2 ||Computer == 2 && choice == 3 || computer == 3 && choice == 1)
{
c.println ("You win!!");
}
else if (choice == 1 && computer == 2 || choice == 2 && computer == 3 || choice == 3 && computer == 1)
{
c.println ("You Lose!!");
}
else if (computer == choice)
{
c.println ("Tryagain!");
}
// Place your program here. 'c' is the output console
} // main method
} // FriedmanRPSgame class
brodeur
0
Newbie Poster
Recommended Answers
Jump to Posthsa.Console? From the context I assume that this class is used for outputting things. I'm just wondering... What is the great benefit of using this class as opposed to using something that comes with the Java libraries? I suggest you to take a look here. You can access an …
Jump to PostAFAIK there isn't anything, which is why I hacked this together a while back.
Feel free to use it without any warrenty.SImply call
ConsoleWindow.withInput();
and continue to use System.out (or err) as usual. Read from System.in as usual, eg via aScanner
.import java.awt.Color; …
All 7 Replies
Taywin
312
Posting Virtuoso
sirlink99
56
Practically a Master Poster
mvmalderen
2,072
Postaholic
sirlink99
56
Practically a Master Poster
mvmalderen
commented:
Oh, okay, I didn't know that.
+13
Zirely
16
Newbie Poster
rproffitt
commented:
This thread is old. Make a new discussion to find the gold.
+16
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Zirely
16
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.