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

Thread: Football Betting System

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Football Betting System

    Hi there I am doing an assignment on Java Programming and need any help on this case study:

    You have been asked to develop a Football Betting System (FBS). The FBS should work as follows:
    You have to create a database containing gaming data (20 team names and team Rating). The program should:
    a. Randomly extract the team names and team rating and put two of each against other;
    b. According to the difference in the rating, the program should show the user the probability of the result (1,X,2) and how much money he would win for each game,
    c. Allow the user to bet on the games by choosing either 1,X, or 2 near each game;
    d. Show the results of the actual random scores and the output them next to the user’s predictions;
    e. Finally calculate the total prize the user won according to the number of bets he won
    Hint - Keep in mind that every difference point in the rating is equal to 1.50 Euro difference in betting. The last amount of money that can be won from a bet is 1.20c

    Any help will be greatly appreciated

    Thanks


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

    Default Re: Football Betting System

    Next step will be for you to design the program you need and write some code.
    Come back here when you have problems.

  3. #3
    Junior Member
    Join Date
    Jun 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Football Betting System

    here is some code on 20 football teams that need to be randomly met with a 1,2, X rating and the score you think im doing ok as i am very new to java

    thanks

    public static void main(String args[])
    Teams teams[]=new team[20];
    teams[0]=(Arsenal,8);
    teams[1]=(AstonVilla,7);
    teams[2]=(Blackburn,6);
    teams[3]=(Bolton,6);
    teams[4]=(Chelsea,8);
    teams[5]=(Everton,7);
    teams[6]=(Fulham,6);
    teams[7]=(Liverpool,8);
    teams[8]=(ManchesterCity,8);
    teams[9]=(ManchesterUnited,9);
    teams[10]=(Newcastle,7);
    teams[11]=(Norwich,4);
    teams[12]=(QPR,4);
    teams[13]=(Stoke,6);
    teams[14]=(Sunderland,6);
    teams[15]=(Swansea,4);
    teams[16]=(Tottenham,7);
    teams[17]=(WBA,5);
    teams[18]=(Wigan,5);
    teams[19]=(Wolves,5);

    public string probability(team a,team b){
    if(a.getrating==b.getrating)
    return "x";
    if(a.getrating>b.getrating)
    return"1";
    else
    return"2"
    }

    team t1;
    team t2;
    int t1goals=-1
    int t2goals=-1

    java.util.Random

    private void generate random score(){
    Random r=new random();
    t1goals=r.next int(7);
    t2goals=r.next int(7);
    }

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

    Default Re: Football Betting System

    Regarding the code you typed in:
    You'd need a definition for the Teams class.
    The syntax is not valid. You create Team objects with: new Team("name", rating)

    Do you have any ideas of what the program should do to implement the steps you listed in post #1?

  5. #5
    Junior Member
    Join Date
    Jun 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Football Betting System

    Hi norm i added some more code not sure what i am doing wrong and thanks for your help

    package betting;


    public class Team {

    private String name; //name of team
    private int rating = 0;

    //constructor of class Team
    public Team(String name, int rating) {
    super();
    this.name = name;
    this.rating = rating;
    }

    //returns the name of the team
    public String getName() {
    return name;
    }

    //sets the name of the team
    public void setName(String name) {
    this.name = name;
    }

    //returns the rating of the team
    public int getRating() {
    return rating;
    }

    // sets the rating of the team to the new parameter
    public void setRating(int rating) {
    this.rating = rating;
    }

    //toString method to return whenever a team is called
    public String toString() {
    return "Team " + name + ", rating = " + rating;
    }
    }



    public static void main(String args[])
    Teams teams[]=new team[20];
    teams[0]=(Arsenal,8);
    teams[1]=(AstonVilla,7);
    teams[2]=(Blackburn,6);
    teams[3]=(Bolton,6);
    teams[4]=(Chelsea,8);
    teams[5]=(Everton,7);
    teams[6]=(Fulham,6);
    teams[7]=(Liverpool,8);
    teams[8]=(ManchesterCity,8);
    teams[9]=(ManchesterUnited,9);
    teams[10]=(Newcastle,7);
    teams[11]=(Norwich,4);
    teams[12]=(QPR,4);
    teams[13]=(Stoke,6);
    teams[14]=(Sunderland,6);
    teams[15]=(Swansea,4);
    teams[16]=(Tottenham,7);
    teams[17]=(WBA,5);
    teams[18]=(Wigan,5);
    teams[19]=(Wolves,5);

    public string probability(team a,team b){
    if(a.getrating==b.getrating)
    return "x";
    if(a.getrating>b.getrating)
    return"1";
    else
    return"2"
    }

    team t1;
    team t2;
    int t1goals=-1
    int t2goals=-1

    java.util.Random

    private void generate random score(){
    Random r=new random();
    t1goals=r.next int(7);
    t2goals=r.next int(7);
    }

    public BetResult getResult() {
    generateRandomScore();//generate actual score
    //returning 1,2 or X according to actual result
    String res;
    if (t1Goals == t2Goals) {
    res = "X";
    } else if (t1Goals > t2Goals) {
    res = "1";
    } else {
    res = "2";
    }
    return new BetResult(res, t1Goals, t2Goals);
    }

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

    Default Re: Football Betting System

    Please wrap your posted code in code tags to preserver formatting. See: BB Code List - Java Forums

    Did you read my comments in post#4 about the syntax for creating Team objects?

    What errors do you get when you compile your program? Please copy and paste them here.

Similar Threads

  1. what is System,out,println in System.out.println()?
    By koteshk in forum Java Theory & Questions
    Replies: 2
    Last Post: April 18th, 2011, 12:28 AM
  2. Fantasy Football Offline Draft Manager Program
    By aussiemcgr in forum Java Theory & Questions
    Replies: 0
    Last Post: September 6th, 2010, 09:52 AM
  3. Football League Table - Idea's?
    By RSYR in forum Java Theory & Questions
    Replies: 1
    Last Post: December 15th, 2009, 07:43 PM
  4. Football Results
    By RSYR in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 4th, 2009, 07:24 PM
  5. System.CurrentTimeMilliseconds
    By Dave in forum Java SE APIs
    Replies: 1
    Last Post: August 26th, 2009, 11:02 AM