Follow us on Twitter!
Understanding is the answer, hatred is the problem, and hackers are the slaves abused and destroyed in the process of peace online - Deshouleres
Wednesday, April 23, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 19
Guests Online: 15
Members Online: 4

Registered Members: 82885
Newest Member: ConiBE
Latest Articles
View Thread

HellBound Hackers | General | Games

Author

Java games....


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 14-06-06 06:26
I got bored and programmed a simple Rock, Paper scissors game, just wondering if someone can help me add something that shows how many games you have played and how many times you have won and lost and such....here is the code....
import java.util.*;
import javax.swing.*;
public class RPS1
{
public static void main(String[] args)
{
JOptionPane.showMessageDialog(null, "Let's play a game of R0ck, P4p3r, Scizz0rz", "Game", JOptionPane.INFORMATION_MESSAGE);

/*Pick your choice of R P S*/
int choice;
int compchoice;
String comment;
Random generator = new Random();
/*infanite loop*/

while(true)
{

choice = Integer.parseInt(JOptionPane.showInputDialog("Choose Rock(0) Paper(1) or Scissors(2)" )); /*i put a space between the "and the ) b/c it made this...."Wink */

/*Random Generator*/

compchoice=generator.nextInt()%3;
comment="";

/* If user picks Rock*/
switch (choice)
{
case (0):
if(compchoice==0)
comment+="Its a draw!";
if(compchoice==1)
comment+="You lose!";
if(compchoice==2)
comment+="You Win!";
break;


/* If user picks Paper*/
case 1:
if(compchoice==0)
comment+="You Lose!";
if(compchoice==1)
comment+="Its a draw!";
if(compchoice==2)
comment+="You Win!";
break;

/*If user picks Scissors*/
case 2:
if(compchoice==0)
comment+="You Lose!";
if(compchoice==1)
comment+="You Win!";
if(compchoice==2)
comment+="Its a draw!" ;
break;

/*If user picks an illegal number*/
default:
comment+="Pick the right number n00b cake!";
break;


}

/* Shows comment after number is inputed*/
JOptionPane.showMessageDialog(null, comment, "Game", JOptionPane.INFORMATION_MESSAGE);
}
}
}




Edited by on 14-06-06 07:08