I have a very basic question:
I have 2 classes; GUI.java & learner.java. The GUI contains a method that is called when it runs that shows an inputDialog , and the user chooses a number between 2 & 10.
And I need the number that the user inputs to be available to me in the learner.java class. So I tried creating a public method that retrieves the number (it is also located in the GUI class):Code:public void setNumChars()throws Exception{ int tmp; do tmp = Integer.parseInt(JOptionPane.showInputDialog("Write num of chars\nbetween 2 and 10:")); while(tmp>10 || tmp<2); numChars = tmp; }
Then I tried using that method in the learner class.Code:public int findNumChars(){ return numChars; }
Now, I know that this doesn't work. My question is; what changes do I have to make to be able to use the user-inputted int from the GUI, in the learner class?Code:public static void learn(String tekst, int orden) { .................... for(int i=0; i<=tekst.length()-(findNumChars() -1); i++) { ........................... if .................... else .................. } }
Really appreciate your help, thanks



Reply With Quote


Bookmarks