/* Online Java - IDE, Code Editor, Compiler Online Java is a quick and easy tool that helps you to build, compile, test your programs online. */ /* The List will create instances of class... List <Club> lst = new ArrayList<>(); Club c = new Leicester_City; lst.add(c); //This will keep a copy List <Club> clubsCopy = new ArrayList<>(lst); The class will furter consist of enums and access content as similar to coding: The list will be of maximum size of 20 corresponding to each team. In terms of NcR if n is not taken to be all objects.. it will simply skip a list item (consisting of the club...) similar to currency application... Can perhaps include something in the logic to allow end users to exclude certain teams (bit advanced) And at the enum level... the enumSet can be restricted to fixture 1 only for instance... Also, some data might not be available for fixutre 2, so this is beneficial. Do not want to overcomplicate it will take 1 event from fixture 1 of the Club(in list) and perform it in accumulator with another. Reason is in real world two markets in same event can be applied on selective markets.... Can expand functionalty later.... */ import java.util.*; import java.text.DecimalFormat; class Club { public Club() { } } public class LeicesterCity extends Club // will potentially remove, unsure... { static DecimalFormat format = new DecimalFormat("##0. 00"); enum Leicester_City //open enum , open Fixture, open and close each constant, { //is this the best way to store the information... it makes sense due to its visibility // but whats best way to populate information in... //perhaps it can get information from a text file? // Text file might have information as such which is clear data..... // For moment, not going to deal with data extraction.. //Assumed data is imported from external source as such /* Club: Leicester Fixture1: Leicester vs Nottingham Forest Under 2.5: 3/4 Over 2.5: 11/8 Full time result: this would be array of ints .. it would need home win, draw, away win.... Time first goal: Fixture 2: Ipswich Town vs Leicester City Under 2.5: Over 2.5: Full time result: this would be array of ints .. it would need home win, draw, away win.... Time first goal: */ //All odds stored, will need to convert to string... //add .0 at end of the numerator and denominator // bring it back //Also this would require severe thought since I also would want to include scoreline odds as //arguments but it would just become far too long.... //perhaps would need to ascertain if the values can be pulled from external source? FIXTURE1 ("Leicester vs Nottingham Forest", "4/11", "8/11", new String []{"4/5", "2/1", "5/2"}) { public void amount () { System.out.println("Format odds"); formatOdds(this.under2Half); // at this moment, it is imagining the logic from //list => adding class instance => class contains enum (with pre-populated data) //need to also understand how random variable will choose the bet type... // also need to decide if worth creating a seperate class for each entity such as club // or better to have one class and all enums inside... (but that will be massively extensive) // if the correct enums are important from the correct file consisting of odds? // Lots of planning required.... } }, //Also this would require severe thought since I also would want to include scoreline odds as //arguments but it would just become far too long.... //perhaps would need to ascertain if the values can be pulled from external source? FIXTURE2 ("Ipswich Town vs Leicester City", "8/11", "5/11", new String []{"3/5", "3/1", "1/1"}) { public void amount () { System.out.println("Format odds"); formatOdds(this.under2Half); // at this moment, it is imagining the logic from //list => adding class instance => class contains enum (with pre-populated data) //need to also understand how random variable will choose the bet type... // also need to decide if worth creating a seperate class for each entity such as club // or better to have one class and all enums inside... (but that will be massively extensive) // if the correct enums are important from the correct file consisting of odds? // Lots of planning required.... } }; // is this to close the fixtures or does it close the entire constants in enum? public abstract void amount(); private Leicester_City() { System.out.println("In constructor"); } public String fixture; public String under2Half; public String over2Half; public String[] fullTimeResult; //Also this would require severe thought since I also would want to include Leicester_City (String fixture, String under2Half, String over2Half, String [] fullTimeResult) { this.fixture=fixture; this.under2Half=under2Half; this.over2Half=over2Half; this.fullTimeResult=fullTimeResult; } }; // THIS IS TO CLOSE THE ENUM public static void formatOdds(String over2Half) // for now, going to imagine this has been selection.... { int pos = over2Half.indexOf("/"); Double num = Double.valueOf (over2Half.substring(0,pos)+".0"); Double den = Double.valueOf (over2Half.substring(pos+1) + ".0"); Double odds = num/den; System.out.println(odds); } public static void main(String[] args) { System.out.println("Welcome to Online IDE!! Happy Coding :)"); // This is now just practicing of enum since this will be used heavily //and it can be quite complicated and versatile if used correctly.... //my next part of the exercise to get good level of information back Leicester_City LC; // variable LC of type enum LC = Leicester_City.FIXTURE1; // this is storing the name of enum constant... System.out.println("This should print out Fixture1: " + LC); System.out.println("This is another way to print Fixture 1:"); System.out.println(Leicester_City.values()[0].name()); //should print Fixture 1. //[0].name() is the same value as the enum constant at enum index 0 System.out.println("\n\nFixture list:"); System.out.println("*****Test to ensure all fixtures can be reached*****"); for (Leicester_City b: Leicester_City.values()) { System.out.println(b.fixture); } System.out.println("\nalternative to see values"); System.out.println("*****Fixture list:****"); // array of type enum... Leicester_City [] allValues = Leicester_City.values(); for (Leicester_City l :allValues) { System.out.println(l); } System.out.println("\nAnother alternative to see values"); for (Leicester_City lc: Leicester_City.values()) { System.out.println(lc); } //This will also get the values and variables associated..... System.out.println("\n********* Or via another way: ********** FIXTURE1"); for (int i=0; i<allValues.length; i++) { System.out.println(LC.values()[i].name()); System.out.println(LC.values()[i].fixture); System.out.println(LC.values()[i].over2Half); System.out.println(LC.values()[i].under2Half); // This code will hit limitation //since its not possible to run the following // since fullTimeResult is non-static and main is static.... //also not possible to change variable..... //Leicester_City.fullTimeResult.length(); //so for time being indexes done manually... if (i==0) { System.out.println("\nFull time result in the String array"); System.out.println(LC.values()[i].fullTimeResult[0]); System.out.println(LC.values()[i].fullTimeResult[1]); System.out.println(LC.values()[i].fullTimeResult[2]); } } // Now the above calculation will only take into consideration Fixture1 // This will become extremely relevant when processing odds since typically // interest will be in Fixture1 in respective Clubs.... System.out.println("\n****************Narrowing the EnumSet******************* " + Leicester_City.FIXTURE1); //it requires two arguments in the range otherwise it will fail... EnumSet <Leicester_City> eSet_Leicester_City = EnumSet.range(Leicester_City.FIXTURE1,Leicester_City.FIXTURE1); int i=0; for (Leicester_City eLC: eSet_Leicester_City) { //Need to avoid this since eSet_Leicester_City is already at the FIXTURE level. This is equivalent to name() // so seeking .values() is at wrong level... System.out.println(eLC.values()); //also indexing is not suitable, similar to any other for each loop //System.out.println(eLC.[0].fixture()); System.out.println("\nNEED TO FOLLOW THIS:"); System.out.println(eLC.name()); System.out.println(eLC.fixture); System.out.println(eLC.under2Half); System.out.println(eLC.over2Half); if (i==0) { System.out.println("\nNeeded for fullltime results:"); System.out.println(eLC.fullTimeResult[0]); System.out.println(eLC.fullTimeResult[1]); System.out.println(eLC.fullTimeResult[2]); System.out.println("\nThis will run through calculation from string to double to get the odd"); //This will give no output //Leicester_City.values()[1].amount(); // This will give output for fixture 1. // Note even though the enumSet is just FIXTURE 1, it still has to treat as if all enum indexes exist. Leicester_City.values()[0].amount(); System.out.println("Validation against fraction: " + Leicester_City.values()[0].under2Half); } //for each is suitable aswell similar to above, since its traversing through fullTimeResult //which is a String array.. However above will only work if it is conducted outside of // main method since the variable fullTimeResult is non-static.... /* for (String s: Leicester_City.fullTimeResult) { System.out.println("\nNeeded for for fullltime results:"); System.out.println(eLC.s); } */ i++; } // Now the calculation will only take into consideration Fixture 2 // This will become extremely relevant when processing odds since typically // interest will be in Fixture1 in respective Clubs.... System.out.println("\n***********Narrowing the EnumSet*************** " + Leicester_City.FIXTURE2); eSet_Leicester_City = EnumSet.range(Leicester_City.FIXTURE2,Leicester_City.FIXTURE2); i=0; for (Leicester_City eLC: eSet_Leicester_City) { //Need to avoid this since eSet_Leicester_City is already at the FIXTURE level. This is equivalent to name() // so seeking .values() is at wrong level... System.out.println("NEED TO AVOID:"); System.out.println(eLC.values()); System.out.println("\nNEED TO FOLLOW THIS:"); System.out.println(eLC.name()); System.out.println(eLC.fixture); System.out.println(eLC.under2Half); System.out.println(eLC.over2Half); if (i==0) { System.out.println("\nNeeded for fullltime results:"); System.out.println(eLC.fullTimeResult[0]); System.out.println(eLC.fullTimeResult[1]); System.out.println(eLC.fullTimeResult[2]); System.out.println("\nThis will run through calculation from string to double to get the odd"); // Note even though the enumSet is just FIXTURE 2, it still has to treat as if all enum indexes exist. Leicester_City.values()[1].amount(); System.out.println("Validation against fraction: " + Leicester_City.values()[1].under2Half); // This is the odds for // This will give no output. //Leicester_City.values()[1].amount(); } i++; } } }