Question
This week our Learning Reflections assignment is short, probably about four lines of code. We will use the Java Collections.sort method to sort the substrings
This week our Learning Reflections assignment is short, probably about four lines of code. We will use the Java Collections.sort method to sort the substrings we generated in last week's generateFrequencies assignment. The substrings are the set of keys in the Map object returned by the generateFrequencies method you implemented last week. You can get this set of substrings with: generateFrequencies(index).keySet(). Since the method you are to write will return an object of type List
We will again use Test Driven Development. The revised Sequences.java file has a new method called getSortedListOfSubstrings that you will implement so that all junit tests will pass in the revised PlainSequencesTest.java junit test file.
Herer is the test code
public void testGetSortedListOfSubstrings() { Sequences tester = new PlainSequences(); String fileName = "plainExampleSmall.text"; try { tester.readSequences(fileName); } catch (FileNotFoundException e) { } //<[A, AG, AGA, C, CA, CAG, CAGA, G, GA, GC, GCA, GCAG, GCAGA, GG, GGC, GGCA, GGCAG, GGCAGA]> List answer = new ArrayList(); answer.add("A"); answer.add("AG"); answer.add("AGA"); answer.add("C"); answer.add("CA"); answer.add("CAG"); answer.add("CAGA"); answer.add("G"); answer.add("GA"); answer.add("GC"); answer.add("GCA"); answer.add("GCAG"); answer.add("GCAGA"); answer.add("GG"); answer.add("GGC"); answer.add("GGCA"); answer.add("GGCAG"); answer.add("GGCAGA");
List sortedSubStrings = tester.getSortedListOfSubstrings(0); assertEquals("the sorted substrings is not right", answer,sortedSubStrings); }
}
here is my code
import java.util.*; import java.io.*;
public class PlainSequences implements Sequences {
private List
public Map
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started