JoesAutomotiveDemo.java:108: error: non-static method getRoutineTotal() cannot be referenced from a static context
subtotal = RoutinePanel.getRoutineTotal() +
^
JoesAutomotiveDemo.java:109: error: non-static method getCleaningTotal() cannot be referenced from a static context
CleaningPanel.getCleaningTotal() +
^
JoesAutomotiveDemo.java:110: error: non-static method getNonRoutineTotal() cannot be referenced from a static context
NonRoutinePanel.getNonRoutineTotal();
^
JoesAutomotiveDemo.java:134: error: non-static method clear() cannot be referenced from a static context
RoutinePanel.clear();
^
JoesAutomotiveDemo.java:135: error: non-static method clear() cannot be referenced from a static context
CleaningPanel.clear();
^
JoesAutomotiveDemo.java:136: error: non-static method clear() cannot be referenced from a static context
NonRoutinePanel.clear();
^
6 errors
Nikki Smith wrote:Anyway, any help is much appreciated.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
You do, however, have a RoutinePanel variable in your JoesAutomotiveDemo class, so try using that.
JoesAutomotiveDemo.java:113: error: unreported exception Exception; must be caught or declared to be thrown
nonRoutine.getNonRoutineTotal();
^
1 error
PS: I gave you a cow for a nicely formatted, well-thought-out question. I wish more people were like you.
Paweł Baczyński wrote:NonRoutinePanel#getNonRoutineTotal() is declared to throw Exception.
That means, whenever you use it it must be enclosed in a try-catch or within a method that also declares it throws the exception (or its superclass).
You don't need throws in this method.
Paweł Baczyński wrote:By the way, the code above could be better. You are throwing an exception in try just to catch and handle it in catch.
That is using an exception for a flow control and should be avoided.
A simple if would suffice.
Nikki Smith wrote:So, if throws is in a method header, then anytime you call that method elsewhere, because throws is in the method header, that means you have to use a try/catch around for the calling statement?
Consider Paul's rocket mass heater. |