Simple Game In Java (Head and Tails).
http://i36.tinypic.com/wl235z.gif
Hi
Please help, i really find it difficult to write a game in java and i really need this ASAP, this is a simple game head and tails.
No LOOPS
The Game
you have to select head or tail then you click start to start the game the computer will select randomly head or tail, If head you won £1 else you lose £1.
buttons:-
START , to start the game
RESET, to reset the game and start from skretch.
Start Agine, to start the game without losing money (blanace)
Head, head
Tail, Tail
Please PM me for sorce code.
Re: Simple Game In Java (Head and Tails).
forgot to say this is just simple game,
I perfer eclipse easy for me to modify it.
Re: Simple Game In Java (Head and Tails).
I could only write as a text base game (useing CMD to run it)
Re: Simple Game In Java (Head and Tails).
Tell us what it is you need help with/what it is you've done so far.
If you just want us to do it for you, I'll move this over to the paid project section.
Re: Simple Game In Java (Head and Tails).
here is an example i have been working on. basicly it does something simmlar to what you want. best of luck
Code :
/**
* @(#)DoubleOrNothing.java
*
* DoubleOrNothing application
*
* @author
* @version 1.00 2009/11/8
*/
import java.util.Scanner;
import java.util.Random;
public class DoubleOrNothing {
public static void main (String[] args) {
Scanner myScanner = new Scanner(System.in);
Random myRandom = new Random();
int bet, money=0, RandomNumber=0, TotalMoney = 0, lost=0, action=1;
// TODO, add your application code
System.out.println("Ok hopfully you have heard of double of nothing");
System.out.println("if not basicly you start off with something and if you get heads");
System.out.println ("you get double your money if tails you get nothing");
do
{
System.out.println ("Type how much money you want to be on");
TotalMoney = myScanner.nextInt();
do
{
if (RandomNumber != 1){
System.out.println ("you have $"+ (TotalMoney) + " 1 = go 2 = stop and run with the money");
action = myScanner.nextInt();
}
if (RandomNumber == 1){
action = 3;
}
if (action == 1){
RandomNumber = (myRandom.nextInt(2) + 1);
if (RandomNumber == 2){
TotalMoney = TotalMoney*2;
System.out.println ("Heads :-D ");
} else if (RandomNumber ==1){
System.out.println ("tails :-( ");
lost = lost + 1;
}
}
if (action == 2){
System.out.print ("you now have $ ");
System.out.println (TotalMoney);
System.out.println ();
RandomNumber = 1;
action = 4;
}
if (action == 3){
System.out.println ("you have lost $" + (TotalMoney));
RandomNumber = 1;
}
if (action == 4) {
RandomNumber = 1;
}
} while (RandomNumber !=1);
RandomNumber = 0;
if (action == 4) {
break;
}
} while (action != 4);
}
}
Re: Simple Game In Java (Head and Tails).
Thanks for that james thats some helpful stuff there :)