Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
6 changes: 6 additions & 0 deletions src/betProperties.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
OddEvenOdds = 50
OddEvenDescription = OddEven
RedBlackOdds = 50
RedBlackDescription = RedBlack
ThreeConsecutiveOdds = 30
ThreeConsecutiveDescription = ThreeConsecutive
54 changes: 54 additions & 0 deletions src/roulette/BetFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package roulette;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.List;
import java.util.ResourceBundle;

public class BetFactory {
List<Bet> betClassList = Arrays.asList(new OddEven(null, 0),new RedBlack(null, 0),new ThreeConsecutive(null, 0));
ResourceBundle betResources = ResourceBundle.getBundle("betProperties");
public BetFactory(){

}
public Bet makeBetClass(String name){
Class c = null;
try {
c = Class.forName(name);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

try {
Constructor betConstructor = null;
try {
betConstructor = c.getConstructor();
} catch (NoSuchMethodException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (SecurityException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

try {
return (Bet) betConstructor.newInstance(betResources.getString(name+"Odds"), betResources.getString(name+"Description"));
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}