Question
Setting up the project ( 2 points ) Create a new Java project called Module01Test_1410 . Add a package called m01 and inside this package,
Setting up the project ( 2 points )
Create a new Java project called Module01Test_1410.
Add a package called m01and inside this package, a class Module01 that includes a main method. The main method is for your own testing in addition to the JUnit test requirements. Inside class Module01, you will declare two public static methods: challenge1 and challenge2. More details are provided below.
In addition, create a second source folder called tests and add the class Module01Test which includes the jUnit tests for both methods.
Style | Doc Comments (4 points)
Follow the style guide and best practices described in Guidelines and Expectations.
Pay special attention to the sections about doc comments and white space (indentation, grouping). All public methods and classes should have doc comments, including the JUnit Test class. However, there is no need to add doc comments for JUnit test methods (methods preceded by @Test).
Method challenge1 (13 points)
Create a public static method challenge1 that has one parameter str of type String and returns a String. It should create and return a new string based on the parameter str and the specifications listed below. (Hint: no recursion needed)
Use appropriate methods from class String and/or StringBuilder to implement the method challenge1. Here are the specifications:
Replaces all dashes (-) with the hash-sign (#) (4 out of 13 points)
Reverses the order of the characters in the string. (4 out of 13 points)
Adds an exclamation mark at the end of the string if it is more than 4 characters long. (4 out of 13 points)
The empty string should return the empty string. (1 out of 13 points)
Examples: The double quotes indicate that the method returns a string, but they should not be included as characters in the string.
challenge1("") returns "" challenge1("-") returns "#" challenge1("abcd") returns "dcba" challenge1("-xx-") returns "#xx#" challenge1("a!b!c") returns "c!b!a!" challenge1("-a --b ---c") returns "c### b## a#!"
Important: the method needs to work with any string passed as an argument. Tip: You'll be asked to write at least 3 JUnit tests based on the examples provided above. Test your method with all the various input strings from the examples, even if you use the main method for some of the testing.
JUnit Tests for challenge1: (7 points)
Write at least three JUnit test methods to test the method challenge1 based on the input data provided in the examples. Each JUnit test method should have a descriptive name. (1 out of 7 points) Tip: Start the name of the JUnit test method with the name of the method you are testing followed by an underscore and a description of the type/category of input you are testing.
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