Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Need help with a program.

  1. #1
    Member
    Join Date
    Jul 2009
    Posts
    31
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Exclamation 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..
    Last edited by MysticDeath; July 29th, 2009 at 09:14 PM.


  2. #2
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Location
    Wales, Bangor & England, Warwickshire
    Posts
    820
    My Mood
    Cynical
    Thanks
    7
    Thanked 104 Times in 90 Posts

    Default 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.
    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


    Chris
    chris[at]javaprogrammingforums[dot]com

    Prifysgol Bangor University, North Wales

  3. The Following User Says Thank You to Freaky Chris For This Useful Post:

    MysticDeath (July 30th, 2009)

  4. #3
    Member
    Join Date
    Jul 2009
    Posts
    31
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default 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!
    Last edited by MysticDeath; July 30th, 2009 at 06:39 PM.

  5. #4
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Location
    Wales, Bangor & England, Warwickshire
    Posts
    820
    My Mood
    Cynical
    Thanks
    7
    Thanked 104 Times in 90 Posts

    Default Re: Need help with a program.

    Glad you solved it, can you mark this thread as solved please.

    Thanks,
    Chris
    chris[at]javaprogrammingforums[dot]com

    Prifysgol Bangor University, North Wales

  6. #5
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: Need help with a program.

    Good work guys.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

Similar Threads

  1. [SOLVED] Method declaration in Java
    By mohsendeveloper in forum Object Oriented Programming
    Replies: 4
    Last Post: June 11th, 2009, 04:18 AM
  2. How to display the contents of my queue?
    By rocafella5007 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 30th, 2009, 12:46 PM
  3. problem with Scanner nextLine() method
    By mia_tech in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: March 10th, 2009, 05:14 AM
  4. Replies: 2
    Last Post: March 4th, 2009, 06:32 AM
  5. Replies: 1
    Last Post: December 30th, 2008, 07:30 AM