Database SQL high school: Soccer round robin?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 08butoryr
    New Member
    • Sep 2007
    • 16

    Database SQL high school: Soccer round robin?

    Hi everyone! this should be pretty simple for programmers on this forum... I need to design a java program which interacts with a MS Access DB in order to simulate the progression of a soccer round robin (e.g. FA Cup). i.e. Select 2 teams (out of 16 teams) randomly to play each other & determine the winner, who therefore plays the winner of one of the other matches etc. until the final winner is determined. I've created a database (SoccerChalleng e) with the following tables: Teams, Round 1 results, Quarter-final results, Semi-final results & Final results. I've already succesfully connected the DB with Administrative tools and displayed the "Teams" table. All I need help with is to:
    1)Randomly select 2 teams from the "Teams" table to play each other - without selecting a team more than once of course.
    2)Determine winner and place them into the next round - I think I have to use something similar to this:
    Code:
    if (goals1 > goals2) { winners[0] = team1;
    NB: I have to do this using JFrame or JOptionPane, no applets preferably. Feel free to suggest any structural changes I should make to my database to make it work as well please. Any bit of help will be very very, very appreciated guys!! Thanks a mil!!
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Don't use those silly arrays: use a List instead and have a look at the very handy
    Collections.shu ffle() method.

    kind regards,

    Jos

    Comment

    • 08butoryr
      New Member
      • Sep 2007
      • 16

      #3
      Originally posted by JosAH
      Don't use those silly arrays: use a List instead and have a look at the very handy
      Collections.shu ffle() method.

      kind regards,

      Jos
      Thank you so much for responding to my thread firstly, I really do appreciate it. I looked up the collections.shu ffle() method and it seems to be the solution. Can you please elaborate on exactly how I'd use it? Thanks again!

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by 08butoryr
        Thank you so much for responding to my thread firstly, I really do appreciate it. I looked up the collections.shu ffle() method and it seems to be the solution. Can you please elaborate on exactly how I'd use it? Thanks again!
        Simply fill a list with all your teams; shuffle it and make eight matches out of
        the sixteen teams. Record the winners. Fill a list with the winners; shuffle it and
        build four matches out of the eight teams. Record the winners, etc. etc.

        kind regards,

        Jos

        Comment

        • 08butoryr
          New Member
          • Sep 2007
          • 16

          #5
          Originally posted by JosAH
          Simply fill a list with all your teams; shuffle it and make eight matches out of
          the sixteen teams. Record the winners. Fill a list with the winners; shuffle it and
          build four matches out of the eight teams. Record the winners, etc. etc.

          kind regards,

          Jos
          Excellent! I'll get right to it tomorrow at school and let you know if I have any problems. Thanks a mil.

          Comment

          • BigDaddyLH
            Recognized Expert Top Contributor
            • Dec 2007
            • 1216

            #6
            I'm guessing you'll want a tutorial on collections: http://java.sun.com/docs/books/tutor...ons/index.html

            Comment

            Working...