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 2 of 2

Thread: Starting one class from another class.

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Starting one class from another class.

    I have an assignment where I am supposed to . . .

    1. Create a class called HiLoGame. This class will just be the driver class to get the game started. It should have the main method and then just create the HiLoGameEngine object and then invoke the method you create in the HiLoGameEngine object to begin playing the game. That is all this class will need to do.

    2. Create a class HiLoGameEngine. This class will implement all the functionality of the game. This class will need to display the information about the game, prompt the user for the low and high-end of the range to guess from, generate the random number for the user to guess, prompt the user to enter a guess, see if the guess is too high, too low, or correct, keep track of the number of guesses, ask the user if s/he wants to play again, etc.

    I've done most of the latter, but I can't figure out how to do the first part to run my code to see what else, if anything I need to do. I've searched online, and have found this:

    public class HiLoGame
    {

    /**
    * @param args
    */
    public void main(String[] args)

    {
    HiLoGame game = new HiLoGame();
    game.startGame();
    }

    }

    It doesn't seem to work through. If someone can explain to me what the game.startGame does and how to use it to call the HiLoGameEngine class, it would be greatly appreciated.


  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Starting one class from another class.

    1. Enclose your code in code tags always.
    2. Where is your HiLoGame code? Post it so that we could look over that.

    startGame() will be the module from where the developer is starting his/her game. You will also have one module you need to initiate the game. Anyways, come up with your code, so far.

    Thanks

Similar Threads

  1. Replies: 7
    Last Post: July 21st, 2011, 02:29 PM
  2. In a class create an array list of elements of another class, help!
    By LadyBelka in forum Collections and Generics
    Replies: 3
    Last Post: May 4th, 2011, 05:00 PM
  3. Replies: 3
    Last Post: April 13th, 2011, 03:30 PM
  4. 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
  5. Replies: 0
    Last Post: April 11th, 2010, 08:56 AM