+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 10 of 16

Thread: Tutorial simple dice game

  1. #1
    Code Warrior Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n's Avatar
    Join Date
    May 2008
    Location
    4chan.org/g/
    Age
    20
    Posts
    3,835
    Blog Entries
    4

    Tutorial simple dice game

    Yet again my own tutorial. This time its a dice game I made.(Of course text based :x, Improvment will later, java isn't my thing )

    So lets begin...
    Code:
    import java.util.*;
    public class mathrandom {
    	protected static Scanner sc = new Scanner(System.in);//The scanner instead of keyboarder
    	
    	public static void main(String[] arg) {
    	
    		
    	
    		System.out.println("Would you like to throw the dice?" +//Input choice
    				"\n1.Yes, please\n2.No thanks");
            int	dice = sc.nextInt();//Operation
    Our choices of operation...
    Code:
    if(dice == 1) {//if the input was 1 then
    	int nr;//Anything in the range of an integer
    	nr = (int)(Math.random()*6+1);//The random selection of number range 1-6
    	
    	System.out.println("You got number "+nr);//Printout the dice number
    	}
    	
    	else if(dice == 2){//else if your choice was 2 then
    	
    	System.out.println("What ever ");//Printout this message
    	
    		}
    	else {//else if your choices were not 1 or 2 then it will close it self
    		System.exit(0);
    	}
    	}
    }
    Now the whole code...
    Code:
    import java.util.*;
    public class mathrandom {
    	protected static Scanner sc = new Scanner(System.in);
    	
    	public static void main(String[] arg) {
    	
    		
    	
    		System.out.println("Would you like to throw the dice?" +
    				"\n1.Yes, please\n2.No thanks");
    	
    	int	dice = sc.nextInt();
    
    	if(dice == 1) {
    	int nr;
    	nr = (int)(Math.random()*6+1);
    	
    	System.out.println("You got number "+nr);
    	}
    	
    	else if(dice == 2){
    	
    	System.out.println("What ever ");
    	
    		}
    	else {
    		System.exit(0);
    	}
    	}
    }
    Hope this simple dice game will entertain you guys when you are bored lol.

    Hatsune Miku ~❤❤❤
    初音ミク。~❤❤❤

  2. #2
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97

    Re: Tutorial simple dice game

    Again, nice code. You should add a bit more description of what your functions do so that new users to Java can learn.

  3. #3
    Code Warrior Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n's Avatar
    Join Date
    May 2008
    Location
    4chan.org/g/
    Age
    20
    Posts
    3,835
    Blog Entries
    4

    Re: Tutorial simple dice game

    Quote Originally Posted by Jordan View Post
    Again, nice code. You should add a bit more description of what your functions do so that new users to Java can learn.
    Thanks, I will try to give more description; But I am not normally good at it

    Hatsune Miku ~❤❤❤
    初音ミク。~❤❤❤

  4. #4
    Newbie shoaibbi is an unknown quantity at this point shoaibbi's Avatar
    Join Date
    Jan 2009
    Posts
    15

    Re: Tutorial simple dice game

    nice and perfect for beginners
    VIvAcIoUs pAkIsTaNi

  5. #5
    Code Warrior Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n's Avatar
    Join Date
    May 2008
    Location
    4chan.org/g/
    Age
    20
    Posts
    3,835
    Blog Entries
    4

    Re: Tutorial simple dice game

    Quote Originally Posted by shoaibbi View Post
    nice and perfect for beginners
    Thank you

    Hatsune Miku ~❤❤❤
    初音ミク。~❤❤❤

  6. #6
    Guru MathX has a spectacular aura about MathX has a spectacular aura about MathX's Avatar
    Join Date
    Oct 2008
    Location
    Kosovo
    Age
    19
    Posts
    4,006

    Re: Tutorial simple dice game

    +rock

  7. #7
    Guru kresh7 is a jewel in the rough kresh7 is a jewel in the rough kresh7 is a jewel in the rough kresh7's Avatar
    Join Date
    Jun 2007
    Location
    Kosovo
    Posts
    652

    Re: Tutorial simple dice game

    +rep

  8. #8
    Code Warrior Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n's Avatar
    Join Date
    May 2008
    Location
    4chan.org/g/
    Age
    20
    Posts
    3,835
    Blog Entries
    4

    Re: Tutorial simple dice game

    Quote Originally Posted by kresh7 View Post
    +rep
    Thank you

    Hatsune Miku ~❤❤❤
    初音ミク。~❤❤❤

  9. #9
    Code Warrior Egz0N is a name known to all Egz0N is a name known to all Egz0N is a name known to all Egz0N is a name known to all Egz0N is a name known to all Egz0N is a name known to all Egz0N's Avatar
    Join Date
    Sep 2008
    Location
    Kosovo
    Age
    18
    Posts
    4,030

    Re: Tutorial simple dice game

    nice one .. +rep

  10. #10
    Code Warrior Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n has much to be proud of Turk4n's Avatar
    Join Date
    May 2008
    Location
    4chan.org/g/
    Age
    20
    Posts
    3,835
    Blog Entries
    4

    Re: Tutorial simple dice game

    Thank you Egz0N

    Hatsune Miku ~❤❤❤
    初音ミク。~❤❤❤

+ Reply to Thread
Page 1 of 2
1 2 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. C# memory game tutorial
    By gaylo565 in forum CSharp Tutorials
    Replies: 37
    Last Post: 10-12-2009, 01:15 PM
  2. Tutorial - A Simple Stropwatch!
    By travy92 in forum VB Tutorials
    Replies: 19
    Last Post: 05-04-2009, 05:02 AM
  3. A simple TicTacToe game
    By Zunone in forum C and C++
    Replies: 1
    Last Post: 08-16-2007, 12:01 PM
  4. need help with simple C++ TicTacToe game with AI
    By flupke1 in forum C and C++
    Replies: 11
    Last Post: 08-14-2007, 11:27 AM
  5. John's Java Tutorial Index
    By John in forum Java Tutorials
    Replies: 0
    Last Post: 01-11-2007, 04:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts