Question: / / color . java package question 5 ; public enum Color { Red, Green, Blue, Purple, Yellow, Teal, Aqua } / / unique tester.java

//color.java
package question5;
public enum Color {
Red,
Green,
Blue,
Purple,
Yellow,
Teal,
Aqua
}
// unique tester.java
package question5;
import java.util.List;
import java.util.Map;
public class UniqueTester {
record Combo(String symbol, Color color){
}
public static Integer countUniqueCombinations(List> data){
return null;
}
}
// question5.java
package question5;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* You are writing a utility that helps identify unique Groupings
* Groups are combos of Strings + colors
* When given multiple maps of these groupings, count how many total unique combos are found
*/
public class Question5{
@Test
public void test(){
List> dataSet = new ArrayList<>();
var map1= new HashMap();
map1.put("A", Color.Teal);
map1.put("B", Color.Red);
var map2= new HashMap();
map2.put("A", Color.Teal);
map2.put("=", Color.Blue);
dataSet.add(map1);
dataSet.add(map2);
Assert.assertEquals((int)UniqueTester.countUniqueCombinations(dataSet),3);
}
@Test
public void test2(){
List> dataSet = new ArrayList<>();
var map1= new HashMap();
map1.put("A", Color.Blue);
map1.put("B", Color.Green);
var map2= new HashMap();
map2.put("A", Color.Red); // just for test, A can't be an
map2.put("C", Color.Yellow);
dataSet.add(map1);
dataSet.add(map2);
Assert.assertEquals((int)UniqueTester.countUniqueCombinations(dataSet),4);
}
@Test
public void test3(){
List> dataSet = new ArrayList<>();
var map1= new HashMap();
map1.put("A", Color.Blue);
map1.put("B", Color.Green);
var map2= new HashMap();
map2.put("C", Color.Red); // just for test, A can't be an
map2.put("D", Color.Yellow);
var map3= new HashMap();
map3.put("E", Color.Teal); // just for test, A can't be an
map3.put("A", Color.Green);
dataSet.add(map1);
dataSet.add(map2);
dataSet.add(map3);
Assert.assertEquals((int)UniqueTester.countUniqueCombinations(dataSet),6);
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!