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.


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

Results 1 to 2 of 2

Thread: Initializing a downloaded class in another class

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Thanked 0 Times in 0 Posts

    Default Initializing a downloaded class in another class

    Im creating a simple craps game, and I have to use a class to come up with random numbers for the game, but Im not sure how to use it. Here's the code for both my work, and the random number class provided, respectively.

    import java.util.Scanner;
    public class EvenOddCraps {

    public static final int MIN_BET = 1;
    public static final int MAX_BET = 31250;

    public static void main(String[] args) {
    Scanner keyboard = new Scanner(System.in);

    int bet, casinoBankTotal = 1000000;

    System.out.println("Would you like to play even/odd craps (y/n)?");
    String input;
    input = keyboard.nextLine();
    char charOne = input.toUpperCase().charAt(0);

    if( charOne == 'Y' ){
    System.out.println("How many chips would you like to bet?");

    bet = keyboard.nextInt();
    input= keyboard.nextLine();
    if( bet >= MIN_BET && bet <= MAX_BET)

    System.out.println("Bet on an even or odd roll (e/o)?");
    String evenOdd;
    evenOdd = keyboard.nextLine();
    char charTwo = evenOdd.toUpperCase().charAt(0);

    if (charTwo == 'E'){
    RandomDie randomdieObject = new RandomDie();




    import java.util.Random;

    /************************************************** *********
    * The RandomDie class contains methods for simulating
    * a roll of fair, six-sided die numbered 1 - 6.
    * This class is used for educational purposes only.
    * @author Sal LaMarca
    * @version 1.0, 02/16/2012
    ************************************************** *********/
    public class RandomDie {

    //The seed value for the random number generator
    private static final long SEED = System.currentTimeMillis();
    //Construct a new random number generator based on the seed
    private static Random randomNumGenerator = new Random(SEED);
    //Set the number of faces on the die
    private static final int FACES_ON_DIE = 6;

    /************************************************** *********
    * Return a random integer of 1, 2, 3, 4, 5, or 6 simulating
    * a roll of a fair, six-side die.
    * @return Return a random integer of 1, 2, 3, 4, 5, or 6.
    ************************************************** *********/
    public static int getRandomDieRoll(){
    return (randomNumGenerator.nextInt(FACES_ON_DIE) + 1);


  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    My Mood
    Thanked 82 Times in 78 Posts
    Blog Entries

    Default Re: Initializing a downloaded class in another class

    Kindly ask an appropriate question to get appropriate answers.

Similar Threads

  1. Replies: 7
    Last Post: July 21st, 2011, 02:29 PM
  2. Replies: 3
    Last Post: April 13th, 2011, 03:30 PM
  3. Help requested - testing a class with a tester class, no methods allowed.
    By miketeezie in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 21st, 2011, 10:40 PM
  4. Replies: 0
    Last Post: April 11th, 2010, 08:56 AM
  5. problem with data access when a class call another class
    By ea09530 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 4th, 2010, 05:20 PM