/* Punters Lounge JAVA programming course * * Lesson53.java * * Requires file/class : Overround.class * * * Author : Erik Datapunter * Date : 28/apr/2004 * * Handling Football odds and results. * */ public class Lesson53 { 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]; // 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 used to calculate the overround double Overround = 0; // variables for betting double Bank = 100; double Stake = 10; double Overodds = 2; // 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; FootballOdds[1][FOhome] = 1.9; FootballOdds[1][FOdraw] = 3.35; FootballOdds[1][FOaway] = 3.85; FootballResult[1][FRhome] = 2; FootballResult[1][FRaway] = 0; FootballOdds[2][FOhome] = 1.5; FootballOdds[2][FOdraw] = 3.75; FootballOdds[2][FOaway] = 5.5; FootballResult[2][FRhome] = 3; FootballResult[2][FRaway] = 2; FootballOdds[3][FOhome] = 1.82; FootballOdds[3][FOdraw] = 3.3; FootballOdds[3][FOaway] = 3.5; FootballResult[3][FRhome] = 0; FootballResult[3][FRaway] = 2; FootballOdds[4][FOhome] = 2.12; FootballOdds[4][FOdraw] = 3.25; FootballOdds[4][FOaway] = 3.5; FootballResult[4][FRhome] = 2; FootballResult[4][FRaway] = 1; FootballOdds[5][FOhome] = 2.42; FootballOdds[5][FOdraw] = 3.25; FootballOdds[5][FOaway] = 2.54; FootballResult[5][FRhome] = 1; FootballResult[5][FRaway] = 2; FootballOdds[6][FOhome] = 1.85; FootballOdds[6][FOdraw] = 3.35; FootballOdds[6][FOaway] = 4; FootballResult[6][FRhome] = 4; FootballResult[6][FRaway] = 8; FootballOdds[7][FOhome] = 1.65; FootballOdds[7][FOdraw] = 3.5; FootballOdds[7][FOaway] = 4.5; FootballResult[7][FRhome] = 0; FootballResult[7][FRaway] = 0; FootballOdds[8][FOhome] = 2.36; FootballOdds[8][FOdraw] = 3.25; FootballOdds[8][FOaway] = 3.05; FootballResult[8][FRhome] = 1; FootballResult[8][FRaway] = 1; FootballOdds[9][FOhome] = 1.12; FootballOdds[9][FOdraw] = 10.5; FootballOdds[9][FOaway] = 34; FootballResult[9][FRhome] = 1; FootballResult[9][FRaway] = 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 Bank = ( Bank - Stake ); // check the number of goals if ( ( FootballResult[matchloop][FRhome] + FootballResult[matchloop][FRaway] ) > 2 ) { // it is an Over so a winning bet, else the bet loses System.out.println("Over"); Bank = Bank + ( Stake * Overodds ); } // display overround and Bank as we go along System.out.println("Match "+matchloop+" = "+Overround); System.out.println("Current bank = "+Bank); } // display final Bank. System.out.println("Final bank = "+Bank); } }