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 4 of 4

Thread: Java Tournament Program

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java Tournament Program

    Hey, I currently have to write a program that will simulate a tournament that takes place between a number of entrants. The details of this program are as follows -

    Learning Outcomes
    This addresses the following learning outcomes
    • Be able to implement, compile, test and run Java programmes, comprising more than
    one class, to address a particular software problem.
    • Demonstrate the ability to employ various types of selection constructs in a Java pro- gram.
    • Demonstrate the ability to employ repetition constructs in a Java program.
    • Demonstrate the ability to use simple data structures like arrays in a Java program.
    Requirements. Design, implement and test a tournament as described below. A tourna- ment is a (ordered) list of players. A player has a name and the number of matches won and lost (non-negative integers). Shown below is a tournament before any matches have been played so the number of matches won and lost is zero in each case. The number at the begin- ning of each line is their current position in the tournament. Initially this will be the order the players are input. The number of games played is calculated from sum of the number of games won and the number lost.
    0: Susie: Played 0, Won 0, Lost 0 1: Abdul: Played 0, Won 0, Lost 0 2: Jean: Played 0, Won 0, Lost 0 3: Pete: Played 0, Won 0, Lost 0 4: Sara: Played 0, Won 0, Lost 0
    A player (a challenger) is allowed to challenge another player (the opponent) who is above them in the list. To challenge a player the position of the challenger and the opponent are input. If the challenger wins, the challenger and the opponent swap positions. For example if Pete challenges Abdul (this is allowed as Abdul is above Pete in the tournament) and wins, Pete moves to position 1 and Abdul moves to position 3. The number of matches played, won and lost are incremented to reflect this. Pete has now played and won one match and Abdul has played and lost one match.
    0: Susie: Played 0 Won 0 Lost 0
    1: Pete: Played 1 Won 1 Lost 0
    2: Jean: Played 0 Won 0 Lost 0
    3: Abdul: Played 1 Won 0 Lost 1
    4: Sara: Played 0 Won 0 Lost 0
    1

    Lab10

    2 If Jean challenges Susie but Jean loses the order remains unchanged. Jean has now played
    and lost one match and Susie has played and won one match.
    0: Susie: Played 1 Won 1 Lost 0 1: Pete: Played 1 Won 1 Lost 0 2: Jean: Played 1 Won 0 Lost 1 3: Abdul: Played 1 Won 0 Lost 1 4: Sara: Played 0 Won 0 Lost 0
    If Pete challenges Jean this is not allowed as Jean is below Pete in the tournament. Similarly a player isn’t allowed to challenge themselves. Initially the names of players should be entered by the user. To represent challenges, the position of the challenger and the opponent are input by the user (using a loop). Assume that the input of a negative challenger position means no more challenges are to be input. Otherwise, if a position is entered that doesn’t exist the user should be informed and allowed to re-enter this.

    I have a few ideas of how best to proceed with this code but i'm not 100% sure. Does any one have any tips or hints that may be able to help? If so please get back to me.

    Thanks, Mike


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Java Tournament Program

    Do you have any specific questions about how to code the program?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java Tournament Program

    Hey thanks for the quick reply. I'm ok at getting all the info input into the program i.e player names etc. but i'm unsure how to actually code the tournament part of it i.e how to allow/ disallow matches to take place depending on their position and how to update the order of these after the simulated result??

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Java Tournament Program

    how to allow/ disallow matches to take place depending on their position
    Sounds like you need to work the the logic.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] Write a java program to display even numbers between 2 and 200 using netbeans java
    By Shalom in forum What's Wrong With My Code?
    Replies: 0
    Last Post: December 11th, 2012, 05:16 AM
  2. Replies: 1
    Last Post: July 8th, 2012, 10:23 AM
  3. how to run a java program..when the program using jar
    By miriyalasrihari in forum Java Theory & Questions
    Replies: 2
    Last Post: May 17th, 2012, 10:04 AM
  4. Java program to Add a JMenu toolbar to a Java Swing application
    By JavaPF in forum Java Swing Tutorials
    Replies: 6
    Last Post: March 6th, 2012, 12:25 PM
  5. Java Error cannot be applied to (java.lang.String), phone book entry program.
    By iceyferrara in forum What's Wrong With My Code?
    Replies: 5
    Last Post: September 23rd, 2011, 06:32 AM

Tags for this Thread