• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

parameter passing

 
Greenhorn
Posts: 4
Firefox Browser Windows XP Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok so i made a game in which a random no. is generated and user have to guess it. The game gives clues like Higher or Lower to user. When a guessed no is found a new jframe opens in a new class gui.class. Now i want to pass the argumets random no and user chances ie counter to gui.class so help me
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> When a guessed no is found a new jframe opens in a new class gui.class.

why?

if the game is gui-based, you'd simply re-use/reset the components

 
Aditya Khare
Greenhorn
Posts: 4
Firefox Browser Windows XP Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
New jframe works as a dialog box that displays random number and the user's chances
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> New jframe works as a dialog box that displays random number and the user's chances

guessing that 'user's chances' means number of guesses made.

if so, use a JOptionPane:

String message = "Random number = " + randomNumber + "\nNumber of guesses made = " + numberOfGuesses;
javax.swing.JOptionPane.showMessageDialog(null, message);
 
All of life is a contant education - Eleanor Roosevelt. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic