Answered step by step
Verified Expert Solution
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 Details
You are given CollectionOfFunctions.java You must write JUnit tests for all of the methods in the class. At least different tests for each method. Once you write one of the tests for a specific method, the other can be easily produced by copyingpasting the first one and adjusting the inputoutput 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 gradeAssignerint grade
ifgrade
return F;
ifgrade
return D;
ifgrade
return C;
ifgrade
return B;
return A;
Sorting Algorithm
Takes in a refrence to an interger array as input and sorts the array.
public void sortArrayint nums
for int i ; i nums.length; i
for int j i; j && numsj numsj; j
int temp numsj ;
numsj numsj;
numsj 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 d array.
public int rowSumint nums, int x
int sum ;
forint j; j numsi
min numsi;
index i;
return new intmin 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 stringCleanerString str char x
String newStr ;
forint i; i
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