Follow us on Twitter!
I'd prefer to die standing, than to live on my knees - Che Guevara
Tuesday, March 03, 2015
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: 21
Guests Online: 19
TeamSpeak Online : 5 Members Online: 2

Registered Members: 87271
Newest Member: Kill Switch
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