Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This problem is asking for me to write a method in the SentenceCounter class tha

ID: 3737331 • Letter: T

Question

This problem is asking for me to write a method in the SentenceCounter class that will pass the test in the images above.

tstatic org.junit.Assert. import org.junit.Before; import org. Junit. Test; make us practice writing loops . Tests that will . eauthor Merlin pra class TestSentencecounter e static final String SENTENCE1 "This is my sentence."; static final String SENTENCE2 privte These words make another sentence that is longer"; te sta rivate SentenceCounter scl; prl private SentenceCounter sc2; . Create two instances we can play with Before ublic void setup() sc1 new SentenceCounter (SENTENCE1) new SentenceCounter (SENTENCE2): Make sure the instance variable is correct @Test public void testconstructor() assertEquals (SENTENCE1, scl.getSentence()) i assertEquals (SENTENCE2, sc2.getSentence ()) Notice that we've already moved the c Before method. This is because we're going to build several tests. It's likely they'1l need to be up this way, so we can predict the duplication we will have and just build the setup method se o an instance of SentenceCounter (which we are about to build). Each of those instances contains a differe right away. At this point, our test class has two instance variables, scl and sc2, that each point we crent sentence because we passed a different sentence into the constructor when created them. This sounds much more complex than it really is.

Explanation / Answer

public class SentenceCounter { private String sentence; public SentenceCounter(String sentence) { this.sentence = sentence; } public String getSentence() { return sentence; } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote