/* Punters Lounge JAVA programming course * * Lesson54.java * * Requires file/class : Overround.class * * * Author : Erik Datapunter * Date : 28/apr/2004 * * Handling Football odds and results. * */ public class Lesson54 { public static void main(String[ ] arguments) { // an Array of 10 rows and 3 columns, respectively 10 matches and 3 odds per match double[][] FootballOdds = new double[10][3]; // an Array of 10 rows and 2 columns, respectively 10 matches and 2 goal scores per match double[][] FootballResult = new double[10][2]; // an Array of 10 rows and 3 columns, respectively 10 matches and 3 possible bet selections double[][] FootballBets = new double[10][3]; // variable names used to acess the info in the Odds Array int FOhome = 0; int FOdraw = 1; int FOaway = 2; // variable names used to acess the info in the Results Array int FRhome = 0; int FRaway = 1; // variable names used to acess the info in the Bets Array int FBhome = 0; int FBdraw = 1; int FBaway = 2; // variable used to calculate the overround double Overround = 0; // variable used to calculate the betting Bank double Bank = 100; // create a new object of the Overround type Overround Over = new Overround(); // a list of 10 football matches with 3 odds each, Home Draw, Away FootballOdds[0][FOhome] = 2.52; FootballOdds[0][FOdraw] = 3.3; FootballOdds[0][FOaway] = 2.46; // a list of 10 football matches with the number of goals for each team, Home and Away FootballResult[0][FRhome] = 1; FootballResult[0][FRaway] = 0; // a list of 10 football matches with the Stakes we have placed on each possible outcome // note: you can place a stake on Home and Draw at the same time. FootballBets[0][FBhome] = 10; FootballBets[0][FBdraw] = 0; FootballBets[0][FBaway] = 0; FootballOdds[1][FOhome] = 1.9; FootballOdds[1][FOdraw] = 3.35; FootballOdds[1][FOaway] = 3.85; FootballResult[1][FRhome] = 2; FootballResult[1][FRaway] = 0; FootballBets[1][FBhome] = 10; FootballBets[1][FBdraw] = 0; FootballBets[1][FBaway] = 0; FootballOdds[2][FOhome] = 1.5; FootballOdds[2][FOdraw] = 3.75; FootballOdds[2][FOaway] = 5.5; FootballResult[2][FRhome] = 3; FootballResult[2][FRaway] = 2; FootballBets[2][FBhome] = 0; FootballBets[2][FBdraw] = 10; FootballBets[2][FBaway] = 0; FootballOdds[3][FOhome] = 1.82; FootballOdds[3][FOdraw] = 3.3; FootballOdds[3][FOaway] = 3.5; FootballResult[3][FRhome] = 0; FootballResult[3][FRaway] = 2; FootballBets[3][FBhome] = 0; FootballBets[3][FBdraw] = 5; FootballBets[3][FBaway] = 10; FootballOdds[4][FOhome] = 2.12; FootballOdds[4][FOdraw] = 3.25; FootballOdds[4][FOaway] = 3.5; FootballResult[4][FRhome] = 2; FootballResult[4][FRaway] = 1; FootballBets[4][FBhome] = 5; FootballBets[4][FBdraw] = 0; FootballBets[4][FBaway] = 0; FootballOdds[5][FOhome] = 2.42; FootballOdds[5][FOdraw] = 3.25; FootballOdds[5][FOaway] = 2.54; FootballResult[5][FRhome] = 1; FootballResult[5][FRaway] = 2; FootballBets[5][FBhome] = 0; FootballBets[5][FBdraw] = 10; FootballBets[5][FBaway] = 0; FootballOdds[6][FOhome] = 1.85; FootballOdds[6][FOdraw] = 3.35; FootballOdds[6][FOaway] = 4; FootballResult[6][FRhome] = 4; FootballResult[6][FRaway] = 8; FootballBets[6][FBhome] = 10; FootballBets[6][FBdraw] = 0; FootballBets[6][FBaway] = 0; FootballOdds[7][FOhome] = 1.65; FootballOdds[7][FOdraw] = 3.5; FootballOdds[7][FOaway] = 4.5; FootballResult[7][FRhome] = 0; FootballResult[7][FRaway] = 0; FootballBets[7][FBhome] = 10; FootballBets[7][FBdraw] = 0; FootballBets[7][FBaway] = 0; FootballOdds[8][FOhome] = 2.36; FootballOdds[8][FOdraw] = 3.25; FootballOdds[8][FOaway] = 3.05; FootballResult[8][FRhome] = 1; FootballResult[8][FRaway] = 1; FootballBets[8][FBhome] = 10; FootballBets[8][FBdraw] = 5; FootballBets[8][FBaway] = 0; FootballOdds[9][FOhome] = 1.12; FootballOdds[9][FOdraw] = 10.5; FootballOdds[9][FOaway] = 34; FootballResult[9][FRhome] = 1; FootballResult[9][FRaway] = 0; FootballBets[9][FBhome] = 10; FootballBets[9][FBdraw] = 0; FootballBets[9][FBaway] = 0; // do it 10 times, once for each match int matchloop; for ( matchloop = 0 ; matchloop < 10 ; matchloop = matchloop + 1 ) { // calculate and display the overround, this time using the method calculate() Overround = Over.calculate( FootballOdds[matchloop][FOhome], FootballOdds[matchloop][FOdraw], FootballOdds[matchloop][FOaway]); // subtract the stake from the bank for each possible bet Bank = ( Bank - FootballBets[matchloop][FBhome] ); Bank = ( Bank - FootballBets[matchloop][FBaway] ); Bank = ( Bank - FootballBets[matchloop][FBdraw] ); // check for a draw if ( FootballResult[matchloop][FRhome] == FootballResult[matchloop][FRaway] ) { // it is a draw System.out.println("Match " + matchloop + " is a Draw."); // calculate a winning bet on the Draw Bank = Bank + (FootballBets[matchloop][FBdraw] * FootballOdds[matchloop][FOdraw]); } // check Home or Away win else if ( FootballResult[matchloop][FRhome] > FootballResult[matchloop][FRaway] ) { // it is a home win System.out.println("Match " + matchloop + " is a Home win."); // calculate a winning bet on the Home team Bank = Bank + (FootballBets[matchloop][FBhome] * FootballOdds[matchloop][FOhome]); } else { // it is a away win System.out.println("Match " + matchloop + " is an Away win."); // calculate a winning bet on the Away team Bank = Bank + (FootballBets[matchloop][FBaway] * FootballOdds[matchloop][FOaway]); } // display overround and bank as we go along System.out.println("Match "+matchloop+" overround = "+Overround); System.out.println("Current bank = "+Bank); } // display final bank System.out.println("Final bank = "+Bank); } }