### Question:
DiscreteDistributionStrategy implements DistributionStrategies<T> { public Distribution<T> parse(String distrAsString) { DiscreteDistribution<T> dist = new DiscreteDistribution<T>(); StringTokenizer tok = new StringTokenizer(distrAsString,","); while (tok.hasMoreElements()) { String pair = tok.nextToken().trim(); StringTokenizer sub = new StringTokenizer(pair,"/"); try { T value = (T) domainType.getConstructor( String.class ).newInstance( sub.nextToken().trim() ); Degree deg = (Degree) getDegreeStringConstructor().newInstance( sub.nextToken().trim() ); dist.put(value,deg); } catch (NoSuchMethodException nsme) { nsme.printStackTrace(); } catch (IllegalAccessException iae) { iae.printStackTrace(); } catch (InstantiationException ie) { ie.printStackTrace(); } catch (InvocationTargetException ite) { ite.printStackTrace(); } } return dist; } DiscreteDistributionStrategy(DegreeType degreeType, Class<T> domainType); Distribution<T> merge(Distribution<T> current,
                                  Distribution<T> newBit); Distribution<T> merge(Distribution<T> current,
			Distribution<T> newBit, String strategy); Distribution<T> merge(Distribution<T> current,
			Distribution<T> newBit, Object... params); Distribution<T> mergeAsNew(Distribution<T> current,
			Distribution<T> newBit); Distribution<T> mergeAsNew(Distribution<T> current,
			Distribution<T> newBit, String strategy); Distribution<T> mergeAsNew(Distribution<T> current,
			Distribution<T> newBit, Object... params); Distribution<T> remove(Distribution<T> current, Distribution<T> newBit); Distribution<T> remove(Distribution<T> current, Distribution<T> newBit, String strategy); Distribution<T> remove(Distribution<T> current, Distribution<T> newBit, Object... params); Distribution<T> removeAsNew(Distribution<T> current, Distribution<T> newBit); Distribution<T> removeAsNew(Distribution<T> current, Distribution<T> newBit, String strategy); Distribution<T> removeAsNew(Distribution<T> current, Distribution<T> newBit, Object... params); void normalize(Distribution<T> distr); Distribution<T> newDistribution(); Distribution<T> newDistribution(Set<T> focalElements); Distribution<T> newDistribution(Map<? extends T, ? extends Degree> elements); T toCrispValue(Distribution<T> dist); T toCrispValue(Distribution<T> dist, String strategy); T toCrispValue(Distribution<T> dist, Object... params); T sample(Distribution<T> dist); T sample(Distribution<T> dist, String strategy); T sample(Distribution<T> dist, Object... params); Distribution<T> toDistribution(T value); Distribution<T> toDistribution(T value, String strategy); Distribution<T> toDistribution(T value, Object... params); Distribution<T> parse(String distrAsString);  }### Answer:
@Test public void testParse() throws Exception { ChanceDegreeTypeRegistry.getSingleInstance().registerDegreeType(DegreeType.SIMPLE, SimpleDegree.class); DiscreteDistribution<String> dd= (DiscreteDistribution<String>) DisDisStrategy.parse("john/0.3, mark/0.7"); assertEquals(0.3,dd.getDegree("john").getValue(),0); assertEquals(0.7,dd.getDegree("mark").getValue(),0); DiscreteDistributionStrategy<Integer> DisDisStrategyInt=new DiscreteDistributionStrategy<Integer>(DegreeType.SIMPLE,Integer.class); DiscreteDistribution<Integer> ddI= (DiscreteDistribution<Integer>) DisDisStrategyInt.parse("5/0.3, 6/0.7"); assertEquals(0.3,ddI.getDegree(5).getValue(),0); assertEquals(0.7,ddI.getDegree(6).getValue(),0); }