Results 1 to 2 of 2
  1. #1
    Ralee is offline Member
    Join Date
    May 2014
    Posts
    1
    Rep Power
    0

    Default How to create a driver program that invokes a class

    Assignment:
    Create a class; call it Lab4a that will have one method called pull. This method does not return anything and requires no parameters.
     In the method, create three random integers in the range 1 to 7. The method will then display the three numbers to the terminal window.
     Now create a driver program, called SlotMachine, to invoke the pull method of the Lab4a class.
     As a refresher, you will have a main method in the driver class that will create an object of Lab4a and then use the only method of this object.
     In your driver program, invoke the roll method 10 times.
     See the back of this lab for an example of the output.


    This is what I have so far.

    Slot machine

    import java.util.Random;
    public class Lab4a
    {
    public static void main (String[]args)
    {

    Random pull=new Random();
    int num1;
    int num2;
    int num3;

    num1=pull.nextInt(7)+1;
    num2=pull.nextInt(7) +1;
    num3=pull.nextInt(7)+1;
    System.out.println ("Three random integers in the range 1-7 are : " +num1 + "," +num2 +"," +num3);


    }
    }



  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,616
    Rep Power
    5

    Default Re: How to create a driver program that invokes a class

    Well for starters, do you have a question? Here is an observation. You don't have a pull method. You have an instance of Random assigned to a variable named pull. Do you know what a method is? And please enclosed your code between code tags. Go to advanced editing. Highlight the code and then click on '#' to wrap the code in code tags.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

Similar Threads

  1. Driver Class Program Help
    By smarty84handsome in forum New To Java
    Replies: 13
    Last Post: 12-08-2013, 10:04 AM
  2. Replies: 5
    Last Post: 08-29-2013, 02:00 PM
  3. Replies: 25
    Last Post: 08-24-2013, 11:08 AM
  4. Replies: 0
    Last Post: 03-03-2012, 01:01 AM
  5. Replies: 10
    Last Post: 04-20-2011, 02:03 AM

Tags for this Thread

Posting Permissions

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