Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

War game with some tweaks

 
Laura White
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all!

I'm working on homework and I'm stuck on a problem. We had to make a Card Class for this game of War that my teacher wants. That was fine but now we need to make a class for the actual game itself and I'm stuck on building the parameterized constructor.

I need to fill player1's ArrayList of cards by traversing the first array of Cards.

I'm having a hard time understand how I add to the p1CardPile's ArrayList using the Card object parameters. When I try .add() eclipse has issues. What am I missing?

Thanks in advance!
 
Laura White
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I may have solved this. This seems to be working:


Now I think I would just add multiple for loops for each of my parameters.
 
Campbell Ritchie
Marshal
Posts: 53094
124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

You shou‍ld have posted the error messages, which might have helped. Anyway, you shorted out the error before anybody else saw your post (well done). I think that is something which the language shouldn't allow, but it does. You have created a method which looks like a constructor. So that is why you couldn't write new Card(...)
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!