Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 2 ) Details You are given CollectionOfFunctions.java You must write JUnit tests for all of the methods in the class. At least 5 different

Question 2) Details
You are given CollectionOfFunctions.java You must write JUnit tests for all of the methods in the class. At least 5 different tests for each method. Once you write one of the tests for a specific method, the other 4 can be easily produced by copying/pasting the first one and adjusting the input/output parameters. it is important to test boundary inputs as most of the bugs are usually
found in those edge cases. If your tests cases are failing, because there is a bug in the given code, then it is okay. You are not required to fix the code; you just need to write the test cases for this assignment.
public class CollectionOfFunctions {
/*
Grade Assigner
Takes in an integer as in input and returns a a letter grade as a character.
*/
public char gradeAssigner(int grade){
if(grade <60)
return 'F';
if(grade <70)
return 'D';
if(grade <80)
return 'C';
if(grade <90)
return 'B';
return 'A';
}
/*
Sorting Algorithm
Takes in a refrence to an interger array as input and sorts the array.
*/
public void sortArray(int[] nums){
for (int i =1; i < nums.length; i++){
for (int j = i; j >0 && nums[j -1]> nums[j]; j--){
int temp = nums[j -1];
nums[j -1]= nums[j];
nums[j]= temp;
}
}
}
/*
Row Summation
Takes in a reference to a multidimensional array and integer x.
Returns the summation of the row at position x in the 2-d array.
*/
public int rowSum(int[][] nums, int x){
int sum =0;
for(int j=0; j nums[i]){
min = nums[i];
index = i;
}
}
return new int[]{min, index};
}
/*
String Cleaner
Takes in as in input a String str and a char x.
Returns a new string that removed all of the characters x from str.
*/
public String stringCleaner(String str, char x){
String newStr ="";
for(int i=0; i

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

Step: 3

blur-text-image

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

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions