Forums Register Login

nothing happens when code runs

+Pie Number of slices to send: Send
+Pie Number of slices to send: Send
Where is your main() method?
+Pie Number of slices to send: Send
Sorry i don't know what you mean by a "main method".  
do you mean "public void run". Or do you mean private int. fnum/snum
+Pie Number of slices to send: Send
I've never used the acm package before, but according to the documentation, ConsoleProgram extends Program, and the Program documentation says

Every application must either contain a "Main-Class" entry in its manifest file or include a main method that looks like this, where MyClass is the name of the program class:

    public static void main(String[] args) {
        new MyClass().start();
     }


All of your readInt() lines are outside any methods, so are seen as instance variable declarations with initializations, which will executed just before the body of the constructor of your class, but you have not created any instances of your class anywhere.
+Pie Number of slices to send: Send
 

Danny Alphones wrote:Sorry i don't know what you mean by a "main method".  
do you mean "public void run".



The main() method is what is called when you run a Java application.  And no... that is *not* the run() method.

Henry
+Pie Number of slices to send: Send
Note that the program extends a class called ConsoleProgram.  I suspect that's the class that provides the main() method that you've been asked about. I also suspect that class calls the run() method.  If this is so, then your program does nothing because your run() method does nothing.
+Pie Number of slices to send: Send
If my suspicions were right, it would have been easier to figure that out if you had written this:

The @Override annotation would have been a clue that the run() method was something that was inherited from the superclass. Notice also blank lines around the method create visual separation. That makes the code easier to read.
+Pie Number of slices to send: Send
This is my new code but still nothing happens
+Pie Number of slices to send: Send
You still don't have a main method. See Fred Kleinschmidt's post up about 4-5.

Also, you should paste your code between the code tags...not after both of them.
+Pie Number of slices to send: Send
fred rosenberger but Junilu Lacar said that my main class is in "ConsoleProgram" witch is probably where my main method() is.
by the way i have run this same class before and everything ran but the code wasnt correct so a made modifications and then when i came to run my code nothing shows up.
+Pie Number of slices to send: Send
When you say nothing happens, do you actually mean an empty Applet Viewer window is displayed, but your are not prompted to enter any data, and nothing printed?

+Pie Number of slices to send: Send
no when i say nothing i mean absolutely nothing shows up .
+Pie Number of slices to send: Send
How are you running the program - from command line, using an IDE, some type of launcher?
+Pie Number of slices to send: Send
im using eclipse 3.2 on java 1.6 .
+Pie Number of slices to send: Send
You can try this to run from Eclipse:
  - right-click on source file (FindRange.java)
  - select Run As
  - select Java Applet

I tried with your code and I do get the applet to start.
+Pie Number of slices to send: Send
for some reason i cant right click the source tab and when i left click it it does not show the name of my class.
+Pie Number of slices to send: Send
never mind, i managed to run it as an applet which is better then nothing but it still did not allow me to do anything on the java applet and it gave me this message Warning: Can't read AppletViewer properties file: C:\Users\Danny\.hotjava\properties Using defaults.
 
+Pie Number of slices to send: Send
You can safely ignore the warning about the property file.

I see two problems with your code:
  - you are not printing the value return by your fnum() and snum() methods
  - you are trying to read input before the run() method is  called

Try reading input from within your run method, and print out the values returned by your methods:


+Pie Number of slices to send: Send
@OP (Danny): You could have saved everyone some time if you had said up front that you are:

1. Studying the Stanford online courses
2. Using this ConsoleProgram

This is what we mean by TellTheDetails (←click that link)
+Pie Number of slices to send: Send
This class is what's providing the main() method for OP's program.
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 4199 times.
Similar Threads
how to fix thus error message "this method must return a result of type int"
Help need in query
About JButton
Manfred please help
java.net.ConnectException: Connection refused: connect during regression
Thread Boost feature
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:29:56.