Jeff Verdegan wrote:Create an instance of the class in question, and refer to the non-static members through a reference to that instance.
Campbell Ritchie wrote:And welcome to the Ranch
yet it still asks me to create static methods / variables
sim on wrote:i did exactly that if you look at the first few lines of code in the example i posted. yet it still asks me to create static methods / variables :<
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
sim on wrote:i did exactly that if you look at the first few lines of code in the example i posted. yet it still asks me to create static methods / variables :<
Because you still have static stuff in your classes.
My advice: Don't put static on ANYTHING except main() for the moment. There'll be plenty of time to discover when and where to use it properly.
Winston
James Boswell wrote:
yet it still asks me to create static methods / variables
Could you elaborate more with an example?
sim on wrote:
Jeff Verdegan wrote:Create an instance of the class in question, and refer to the non-static members through a reference to that instance.
i did exactly that if you look at the first few lines of code in the example i posted. yet it still asks me to create static methods / variables :<
cleaned it up a bit
sim on wrote:
i removed all of the static calls execpt on the main but i still get the message that they need to be static in order for me to call Car.getRegNum() inside carOwner
sim on wrote:i removed all of the static calls execpt on the main but i still get the message
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
James Boswell wrote:I don't think that is the problem. The OP's code is calling methods statically when they aren't static and the compiler is complaining.
James Boswell wrote:Jeff
This is what is happening (look at few posts back)
The call to the bar method assumes it is static which it isn't.
James Boswell wrote:Jeff
I think we need the OP at this point to enlighten us further.
James Boswell wrote:I don't think that is the problem. The OP's code is calling methods statically...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
James Boswell wrote:In the Buy and Sell methods (or buy and sell as Jeff rightly points out), you are calling methods on the Car class statically.
E.g.
As you are passing a Car reference c to the methods, you should be doing this:
James Boswell wrote:Bear/Jeff
Right, here is my take on this.
The last time the OP posted was at 10:05:52. Here is the code he presented in that post:
Hence, my comment that he is attempting to call non-static methods in a static manner i.e. the calls to getRegNum()
[Edit]I think the OP has left us to it
Don't get me started about those stupid light bulbs. |