@Test public void testBranchNumberAdder(){ try { classPair.addTonumberOfBranches("",2); fail("IllegalStateException expected!"); }catch(IllegalStateException e){ assertTrue(e.getMessage().contains("Class is not available!")); } }
public void addTonumberOfBranches(String className, int value){ if(value <= 0 ){ return; } if(className.equals(class1)){ numberOfBranchesInClass1+=value; }else if (className.equals(class2)){ numberOfBranchesInClass2+=value; }else{ throw new IllegalStateException("Class is not available!"); } }
ClassPair implements Comparable<ClassPair> { public void addTonumberOfBranches(String className, int value){ if(value <= 0 ){ return; } if(className.equals(class1)){ numberOfBranchesInClass1+=value; }else if (className.equals(class2)){ numberOfBranchesInClass2+=value; }else{ throw new IllegalStateException("Class is not available!"); } } }
ClassPair implements Comparable<ClassPair> { public void addTonumberOfBranches(String className, int value){ if(value <= 0 ){ return; } if(className.equals(class1)){ numberOfBranchesInClass1+=value; }else if (className.equals(class2)){ numberOfBranchesInClass2+=value; }else{ throw new IllegalStateException("Class is not available!"); } } ClassPair(String class1, String class2, int score1, int score2); }
ClassPair implements Comparable<ClassPair> { public void addTonumberOfBranches(String className, int value){ if(value <= 0 ){ return; } if(className.equals(class1)){ numberOfBranchesInClass1+=value; }else if (className.equals(class2)){ numberOfBranchesInClass2+=value; }else{ throw new IllegalStateException("Class is not available!"); } } ClassPair(String class1, String class2, int score1, int score2); @Override boolean equals(Object obj); @Override int compareTo(ClassPair otherPair); String getClass1(); String getClass2(); int getCallScore1(); int getCallScore2(); int getTotalScore(); int getNumberOfBranchesInClass1(); int getNumberOfBranchesInClass2(); void addTonumberOfBranches(String className, int value); List<Integer> getListOfObjectivesValue(); }
ClassPair implements Comparable<ClassPair> { public void addTonumberOfBranches(String className, int value){ if(value <= 0 ){ return; } if(className.equals(class1)){ numberOfBranchesInClass1+=value; }else if (className.equals(class2)){ numberOfBranchesInClass2+=value; }else{ throw new IllegalStateException("Class is not available!"); } } ClassPair(String class1, String class2, int score1, int score2); @Override boolean equals(Object obj); @Override int compareTo(ClassPair otherPair); String getClass1(); String getClass2(); int getCallScore1(); int getCallScore2(); int getTotalScore(); int getNumberOfBranchesInClass1(); int getNumberOfBranchesInClass2(); void addTonumberOfBranches(String className, int value); List<Integer> getListOfObjectivesValue();  }