Need help with a program.
Ok, so I will be making a Set game http://en.wikipedia.org/wiki/Set_(game) in Java, but I've realized a simple flaw..
I have no idea how I should identify the sets.
My pro will print out all the possible combinations.
Before making this horrifying, and long GUI, I want to know a method of some sort to identify a set.
I've been thinking there must be some kind of for loop that would work..
Re: Need help with a program.
From my understanding of the game, you can check it with a couple of if statements. Depending on how you have stored the infrmation for each card. But you need to check all the different rules. Such as are they all the same colour or all different colours? that could all be put together as one if statement. Something like.
Code :
if((card1.colour == card2.colour && card1.colour == card3.colour) || (card1.colour != card2.colour && card1.colour != card3.colour && card2.colour != card3.colour)){
//Do something
}
That would cover one of the rules, all ou would need to do was change colour to shape etc for the others. If that was how you stored he information ofcourse :P
Chris
Re: Need help with a program.
That is precisely what I mean, but that would take more than "several" im guessing.
But I'll test it out and tell you how it goes. @-)
EDIT: I'm writing it now, it would take around 16 if || statements.
EDIT: Now that I'm writing it, how would I get the source of the matches.
I would like the program to print out which cards form a set.
And you should take into mind I'll be using 12 cards. so I can't just to print out the 3 cards that we are using.. XD
EDIT: Never mind. I've cleverly engineered a way for this.
Thank you very much. Case closed!
Re: Need help with a program.
Glad you solved it, can you mark this thread as solved please.
Thanks,
Chris
Re: Need help with a program.