Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Calling function

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am calling function in one class from another class. The Class 1(Answer1 in below code) allows user to enter their answer in the text box. Once the answer is entered and submit button is clicked I want the control to come back to jeopardy class from where it is called and continues with the next step.
From Jeopardy when I am calling the control does not come back ansd execute the next step which is String input = a.get_s(); In Jeopardy class,  I  need help .


Below is the code....

Posts: 69403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch sorry nobody has replied earlier.

Nice to see properly indented code, but I think some of your lines (146‑152) are too long. Rather than using drawString(), consider using a JLabel with all the help text passed as a constructor argument.
I am afraid there is a lot more to say, most of it not good.
Why are you using an Applet? Applets are obsolete.
I think you have some other design problems about how many classes you have. There are very few instances where you should inherrit from a GUI display class. And it is usually a bod idea to make display classes implement ActionListener. It is better to add an action listener to a button. It is also usually a bad idea to make a display class play a game.
I think you need to change a lot:-
  • 1: Write the game in its own classes. Get it working without any GUI classes at all.
  • 2: Make sure you have enough classes. Lines 115‑136 don't suggest object‑orientation to me. I would have a Player class, with a certain number of instances, and a way of moving those instances into and out of play as they take turns.
  • 3: Make your methods much much smaller. If you have a ten‑line method, try and refactor it into two five‑line methods.
  • 4: No static variables. I don't know whether that is the cause of your problem, but it is a mistake to make anything static without a good reason.
  • 5: Make all fields except those used as global constants private.
  • 6: No GUIs until all that lot is working. Only then should you even think of a GUI.
  • You only need one Scanner instance per application, so I often make Scanners static, but why are you using a Scanner at all? If you have a GUI, use that to receive any information from the users.
    My, my, aren't you a big fella. Here, have a tiny ad:
    Devious Experiments for a Truly Passive Greenhouse!
      Bookmark Topic Watch Topic
    • New Topic