Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Simple Game In Java (Head and Tails).

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Simple Game In Java (Head and Tails).



    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.


  2. #2
    Junior Member
    Join Date
    Nov 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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.

  3. #3
    Junior Member
    Join Date
    Nov 2009
    Posts
    9
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Simple Game In Java (Head and Tails).

    I could only write as a text base game (useing CMD to run it)

  4. #4
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default 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.

  5. #5
    Junior Member
    Join Date
    Nov 2009
    Posts
    9
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default 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

    /**
     * @(#)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);
        	}
        }

  6. The Following User Says Thank You to james137 For This Useful Post:

    Sneak (November 28th, 2009)

  7. #6
    Junior Member
    Join Date
    Nov 2009
    Posts
    12
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Simple Game In Java (Head and Tails).

    Thanks for that james thats some helpful stuff there

Similar Threads

  1. Programmer for a Java based game project
    By Takkun in forum Project Collaboration
    Replies: 4
    Last Post: June 14th, 2010, 05:47 PM
  2. Hiring a JAVA coder for a online game
    By Kryptix in forum Paid Java Projects
    Replies: 0
    Last Post: October 30th, 2009, 10:39 PM
  3. Robo Code - The funny Java Programming Game
    By Freaky Chris in forum The Cafe
    Replies: 20
    Last Post: October 8th, 2009, 03:42 PM
  4. help with simple java program
    By parvez07 in forum Java Theory & Questions
    Replies: 4
    Last Post: August 25th, 2009, 07:19 AM
  5. Problem while programming a simple game of Car moving on a road
    By rojroj in forum Java Theory & Questions
    Replies: 3
    Last Post: April 2nd, 2009, 10:24 AM