diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..fb50116 --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/roulette/BetFactory.java b/src/roulette/BetFactory.java new file mode 100644 index 0000000..ceb9dd0 --- /dev/null +++ b/src/roulette/BetFactory.java @@ -0,0 +1,22 @@ +package roulette; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + + +public class BetFactory { + + public BetFactory () { + // Do nothing + } + + public Bet getBet (String bet) throws ClassNotFoundException, NoSuchMethodException, + SecurityException, InstantiationException, + IllegalAccessException, IllegalArgumentException, + InvocationTargetException { + Class betClass = Class.forName(bet); + Constructor betConstructor = betClass.getConstructor(double.class); + return (Bet) betConstructor.newInstance(); + } + +}