Hi, I'm new here. I'm kinda behind on my school work due to me going into labor early. So, I'm doing an assignment and the next thing I have to do is 'call the generate method and display the numbers for all four games,' and I'm stuck. Also I keep getting an error that says 'missing return type.' I would really appreciate if someone could help.:)

// Exercise 15.13: LotteryPicker.java
// This application picks randomly generated numbers for a lottery.
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import java.util.Random;
import javax.swing.*;
public class LotteryPicker extends JFrame
{
   // JLabel and JTextField to display three number lottery
   private JLabel threeJLabel;
   private JTextField output3JTextField;
   // JLabel and JTextField to display four number lottery
   private JLabel fourJLabel;
   private JTextField output4JTextField;
   // JLabel and JTextField to display five number lottery
   private JLabel fiveJLabel;
   private JTextField output5JTextField;
   // JLabel and JTextField to display five number + one lottery
   private JLabel fivePlus1JLabel;
   private JTextField output5Plus1JTextField;
   private JTextField outputExtra1JTextField; 
   // JButton to generate new lottery numbers
   private JButton generateJButton;
   // create a new Random object
   private Random generator = new Random();
   
   // no-argument constructor
   public LotteryPicker()
   {
      createUserInterface();
   }
   
   // create and position GUI components; register event handlers
   private void createUserInterface()
   {
      // get content pane for attaching GUI components
      Container contentPane = getContentPane();
      // enable explicit positioning of GUI components
      contentPane.setLayout( null );
      // set up threeJLabel
      threeJLabel = new JLabel();
      threeJLabel.setText( "Three number lottery:" );
      threeJLabel.setBounds( 16, 18, 132, 16 );
      contentPane.add( threeJLabel );
      // set up output3JTextField
      output3JTextField = new JTextField();
      output3JTextField.setBounds( 152, 16, 124, 23 );
      output3JTextField.setHorizontalAlignment( JTextField.CENTER );
      output3JTextField.setEditable( false );
      contentPane.add( output3JTextField );
      // set up fourJLabel
      fourJLabel = new JLabel();
      fourJLabel.setText( "Four number lottery:" );
      fourJLabel.setBounds( 16, 50, 132, 16 );
      contentPane.add( fourJLabel );
      // set up output4JTextField
      output4JTextField = new JTextField();
      output4JTextField.setBounds( 152, 48, 124, 23 );
      output4JTextField.setHorizontalAlignment( JTextField.CENTER );
      output4JTextField.setEditable( false );
      contentPane.add( output4JTextField );
      // set up fiveJLabel
      fiveJLabel = new JLabel();
      fiveJLabel.setText( "Five number lottery:" );
      fiveJLabel.setBounds( 16, 82, 132, 16 );
      contentPane.add( fiveJLabel );
      // set up output5JTextField
      output5JTextField = new JTextField();
      output5JTextField.setBounds( 152, 80, 124, 23 );
      output5JTextField.setHorizontalAlignment( JTextField.CENTER );
      output5JTextField.setEditable( false );
      contentPane.add( output5JTextField );
      // set up fivePlus1JLabel
      fivePlus1JLabel = new JLabel();
      fivePlus1JLabel.setText( "Five number + 1 lottery:" );
      fivePlus1JLabel.setBounds( 16, 114, 132, 16 );
      contentPane.add( fivePlus1JLabel );
      // set up output5Plus1JTextField
      output5Plus1JTextField = new JTextField();
      output5Plus1JTextField.setBounds( 152, 112, 92, 23 );
      output5Plus1JTextField.setHorizontalAlignment(
         JTextField.CENTER );
      output5Plus1JTextField.setEditable( false );
      contentPane.add( output5Plus1JTextField );
      // set up outputExtra1JTextField
      outputExtra1JTextField = new JTextField();
      outputExtra1JTextField.setBounds( 252, 112, 24, 23 );
      outputExtra1JTextField.setHorizontalAlignment(
         JTextField.CENTER );
      outputExtra1JTextField.setEditable( false );
      contentPane.add( outputExtra1JTextField );
      // set up generateJButton
      generateJButton = new JButton();
      generateJButton.setText( "Generate" );
      generateJButton.setBounds( 180, 152, 96, 24 );
      contentPane.add( generateJButton );
      generateJButton.addActionListener( 
      
         new ActionListener() // anonymous inner class
         {
            // event handler called when generateJButton is pressed
            public void actionPerformed( ActionEvent event )
            {
               generateJButtonActionPerformed( event );
            }
            
         } // end anonymous inner class
         
      ); // end call to addActionListener
      // set properties of application's window
      setTitle( "Lottery Picker" ); // set title bar string
      setSize( 300, 216 );          // set window size
      setVisible( true );           // display window
      
   } // end method createUserInterface
   
   // generate random lottery numbers
   private void generateJButtonActionPerformed( ActionEvent event )
   {
    
    
   } // end method generateJButtonActionPerformed
   
   // generate random number in a given range from low to high
    private String generate( int low, int high )
    {
      
     Random randomGenerator  = new Random(); 
     int randomNumber = randomGenerator.nextInt();
        
    } // end generate random number method
    
    
   // main method
   public static void main( String[] args )
   {
      LotteryPicker application = new LotteryPicker();
      application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
   } // end method main
   
} // end class LotteryPicker

You are writing the return type of method as String but where is your return statement in method ...? So you are receiving this error "missing return type"

private String generate( int low, int high )

{[INDENT]-[/INDENT]

[INDENT]-[/INDENT]


[INDENT]return SomeStringValue[/INDENT]
}

You didn't called generate method anywhere ....!! So call this method on the actionPerformed event of genereate button and display the result.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.