Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tower's of Hanoi using Stacks - Java
#13
MoldyBunny Wrote:-snip-

That gives me:
Code:
Exception in thread "main" java.lang.NullPointerException
    at Tower.addDisc(Tower.java:11)
    at TOHModel.<init>(TOHModel.java:10)
    at TOHFrame.<init>(TOHFrame.java:7)
    at TOHApp.main(TOHApp.java:5)
Java Result: 1

Which indicates there is a problem with Tower.
I wish I learned objects more in depth.

s is null according to the debugger, but I thought having
Code:
private Stack s;
    
    public void Tower(){
        s = new ArrayListStack();
    }
initialized it?

EDIT:
GOT IT.
I had public void Tower(), should be public Tower().
Derp mistake.

I WILL BE UPDATING THIS THREAD WITH MORE PROBLEMS, THOUGH. Thanks guys!

now to figure out how to paint the discs
Reply


Messages In This Thread
Tower's of Hanoi using Stacks - Java - by XTOTHEL - 2012-03-10, 07:02 PM
Tower's of Hanoi using Stacks - Java - by XTOTHEL - 2012-03-10, 07:58 PM
Tower's of Hanoi using Stacks - Java - by XTOTHEL - 2012-03-10, 08:02 PM
Tower's of Hanoi using Stacks - Java - by XTOTHEL - 2012-03-10, 08:25 PM
Tower's of Hanoi using Stacks - Java - by Marksman Bryan - 2012-03-10, 08:41 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)