Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Databases Theory And Applications 27th Australasian Database Conference Adc 20 Sydney Nsw September 28 29 20 Proceedings Lncs 9877

Authors: Muhammad Aamir Cheema ,Wenjie Zhang ,Lijun Chang

1st Edition

3319469215, 978-3319469218

More Books

Students also viewed these Databases questions

Question

What is the principle of thermodynamics? Explain with examples

Answered: 1 week ago

Question

Explain the strength of acid and alkali solutions with examples

Answered: 1 week ago

Question

1. Define the nature of interviews

Answered: 1 week ago

Question

2. Outline the different types of interviews

Answered: 1 week ago