• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help with my Java applet

 
Greenhorn
Posts: 10
Eclipse IDE MySQL Database PHP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I have two questions.

1 - I don't understand why I'm getting an empty stack error when calling the removecard method in my Table class line 13?

2 - I am trying to use a constructor to populate my deck of cards instead of a method when creating my theDeck object in my Table class line 11 but I get the following error:

java.lang.StackOverflowError
at java.util.Vector.<init>(Unknown Source)
at java.util.Vector.<init>(Unknown Source)
at java.util.Stack.<init>(Unknown Source)
at Deck.<init>(Deck.java:7)
at Deck.<init>(Deck.java:34)







Thank you for your time.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A couple things you may want to start with:

Never compare strings with the "==" operator, always use the "equals" method.

Deck.buildDeck allocates a Deck object - it should not. A Deck object has already been allocated in the Table class. Instead of calling the various "deck.XYZ()" methods, buildDeck should call "XYZ()" directly.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the way, I'm not getting the error you observed, just an "Error, empty stack" because of the problem in the Deck class I mentioned. If I fix that, everything looks normal (well, as expected, anyway :-) ).

As long as you don't have a GUI inplace, you may want to redefine you Table class like this so you can run it from the command line without the applet stuff:

 
Alex Desjardins
Greenhorn
Posts: 10
Eclipse IDE MySQL Database PHP
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey, thank you Ulf Dittmer, now I understand! I still have to go over everything but that makes sense. Again thank you for your help ; ) And I will fix the equal thing when comparing strings.

Edit:

And the constructor is working now.
reply
    Bookmark Topic Watch Topic
  • New Topic