Follow us on Twitter!
Things are more like they are now than they have ever been before. - Dwight D. Eisenhower
Tuesday, April 28, 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: 19
Guests Online: 17
TeamSpeak Online : 5 Members Online: 2

Registered Members: 88087
Newest Member: zombiecomp
Latest Articles
Our sponsor needs your help!


One of our sponsors needs your help, http://www.virginmediabusiness.co.uk/pitch-to-rich/grow/krystal-hosting/
Go check out their video and Don't forget to vote !


~ Thanks for your help
HBH
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