Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This exercise will help you to practice manipulating Strings and using JUnit. If you don't finish during class, please continue to work on it at

image text in transcribed
This exercise will help you to practice manipulating Strings and using JUnit. If you don't finish during class, please continue to work on it at home. Visit us during office hours if you have questions. Open a window where you can view the documentation for the String class API. You may use any String methods that you find convenient. 1. 2. Create a project called "Lab18" 3. Create a class called StringTools 4. Create JUnit test case called "String ToolsTesting 5. Write the following methods in the String Tools class. After completing each method, write a THOROUGH JUnit test for it in the StringToolsTesting class. Be sure that you are testing several "typical" cases, and also any "corner cases" you can think of. Run your tests each time to see if your method is working properly in all cases. a. public static int count (String a, char c) Returns the number of times the character c appears in the String a. b. public static int countSubstring (String a, String b) Returns the number of times the String b occurs inside of the String a. For example, if a is "Mississippi, and b is "issi", then the return value would be 2. (Note that the occurrences of the substring may overlap!) c. public static String reverse (String a) Returns a copy of the parameter, but with the letters reversed. For example, if the parameter is "monkey", then the return value would be "yeknom". d. public static String expand (String a) Returns a String comprised of: One copy of the first character from a, two copies of the second charact then the return value would be "Frreeedddd". er from a, three copies of the third character, etc. For example, if the parameter is "Fred e. public static String alternating (String a, String b) Returns a string formed using alternating letters from a and b. For example, if a is "cow and b is "buffalo", then the return value would be "cbouwffalo". Note that either parameter could be the longer of the two f. public static String linkExtractor(String a) Looks inside the parameter for a substring of the form: href "something Where there could be 0 or more spaces on either side of the equals sign, and there could be anything between the quotes. If such a substring exists, return it. Otherwise, return null

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Issues In Database Management A Refernce For The Thinking Practitioner

Authors: Fabian Pascal

1st Edition

0201485559, 978-0201485554

More Books

Students also viewed these Databases questions