Question: Java question: Test Driven Development (TDD) is a popular Software Engineering practice where developers write tests first before writing code. For this problem, you will

Java question:

Test Driven Development (TDD) is a popular Software Engineering practice where developers write tests first before writing code. For this problem, you will be creating test cases for classes that implement the interface described below:

public interface NumberFormatter { String format(int n); }

Consider three classes that implement this interface. A DecimalSeparatorFormatter formats an integer with decimal separators; for example, one million as 1,000,000. An AccountingFormatter formats negative numbers with parentheses; for example, 1 as (1). A BaseFormatter formats the number in base n, where n is any number between 2 and 36 that is provided in the constructor (i.e, the constructor in the BaseFormatter class takes one integer parameter that specifies the base to be used for conversion). Write a test class called NumberFormatterTests that includes test cases for the above-mentioned three classes. Sample expected output is given below:

DecimalSeparatorFormatter

38756 -> 38,756

956432 -> 956,432

AccountingFormatter

-987654321 -> (987654321)

-287 -> (287) BaseFormatter 100 -> 100 [Base 10]

21 -> 10101 [Base 2]

1194684 -> 123ABC [Base 16]

Write test cases for valid and invalid input.

You are NOT expected to write the corresponding classes. Your grade will be determined based on the extent to which your test cases pass against the code that the TAs will use for grading. You will not have access to this code.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!