Java

For this problem set, you will submit a single java file named Homework.java. You are supposed to add the functions described below to your Homework class. The functional signatures of the functions you create must exactly match the signatures in the problem titles. You are not allowed to use any 3rd party libraries in the homework assignment nor are you allowed to use any dependencies from the java.util package besides the Pattern Class. When you hava completed your homework, upload the Homework.java file to Grader Than. All tests will timeout and fail if your code takes longer than 10 seconds to complete.

 
privateFunction()
This is a private non-static function that takes no arguments and returns an integer.
You don’t need to put any code in this function, you may leave the function’s code empty. Don’t overthink this problem. This is to test your knowledge on how to create a non-static private function.
Arguments:
returns int – You may choose any integer you would like.
protectedFunction(String, int)
This is a protected non-static function that takes a String and an int as its arguments and returns nothing.
You don’t need to put any code in this function, you may leave the function’s code empty. Don’t overthink this problem. This is to test your knowledge on how to create a non-static protected function.
Arguments:
String text – An string
String int – An integer
countOccurrences(String[], String)
This is a public static function that takes a String[] and a string for the parameters and returns an int.
This function should count the number of times a given pattern (the second parameter) is found within each string in an array of strings (first parameter). Then the function should return the total number of occurrences. 
Arguments:
String[] array – An array containing at least one string
String pattern – A string containing at least one character.
returns int – The number of times the pattern is found in the strings in the array. 
Example:
array = [“aba”, “ckel”, “kealska”]
pattern = “a”
output = 4
mergeAndRemove(int[], int[])
This is a public static function that takes a int[] and int[] for the parameters and returns an int[].
Given two arrays of integers. Your job is to combine them into a single array and remove any duplicates, finally return the merged array. 
Arguments:
int[] array_1 – An array of integers
int[] array_2 – An array of integers
returns int[] – An array of integers containing the unique values from both array_1 and array_2
Example: 
array_1 = [1,2,3]
array_2 = [2,3,4]
output = [1,2,3,4]
pairRemoval(String, String, String)
This is a public static function that takes three Strings as arguments and returns a String.
You will be given three strings, the first string is a sentence known as text that contains at least one occurrence of left pattern and right pattern. The second and third arguments of the function are the left and right patterns respectively. Left pattern and right pattern are single characters strings that you are attempting to remove from the string. Your goal is to remove only the patterns when the left pattern has an equal number of corresponding right patterns. The patterns are removed in pairs only when there is a balanced number of left and right patterns. The patterns may be nested within the text and there is no guarantee that a left pattern will occur before the right pattern.   
Arguments:
String text – The string with the substring to be removed
String leftPattern – A pattern that the substring must start with
String rightPattern – A pattern that the substring must end with
returns String – The given text with the paired patterns removed
Example:
Example 1: 
text = { { Muscat } } { } mecum tollgate } poultry quarrymen pantheon asteria 
leftPattern = {
rightPattern = }
return = Muscat mecum tollgate } poultry quarrymen pantheon asteria
Example 2: 
text = merioneth ( smickly helotage yarr ) ethmoidal ) ) ) digitinervate
leftPattern = (
rightPattern = )
return =. merioneth smickly helotage yarr ethmoidal ) ) ) digitinervate
Example 3: 
text = southland palladic } { pasillo { } seeableness } { { normanesque
leftPattern = {
rightPattern = }
return = southland palladic pasillo seeableness { normanesque
rotateMatrix(int, int[][])
This is a public static function that takes an int and an int[][] for the parameters and returns an int[][]. Note an int[][] is an array with int arrays within it. this is often referred to as a 2-dimensional array.
You must rotate a square matrix counter-clockwise or clockwise 90 degrees an arbitrary number of times. You will be given a matrix of integers (otherwise known as a 2-dimensional array), that has equal height and width. The dimension can range from 2×2 – 10×10. You will also be given an integer that may range from -100 to 100, this integer will indicate which direction to rotate the matrix and how many times to rotate it. You are expected to return the rotated matrix. 
Arguments:
int direction – The number of rotations in a particular direction. If > 0 rotate the specified amount of times clockwise. else if < 0 rotate the specified amount of times counterclockwise. Otherwise, no rotations are expected.
int[][] matrix – A 2-dimensional array of integers that is to be rotated.
returns int[][] – The rotated matrix.
Example:
Rotations: 25
Matrix: [[0,6,6,5],[16,7,12,11],[16,19,2,16],[12,15,2,5]]
Output:[[12,16,16,0],[15,19,7,6],[2,2,12,6],[5,16,11,5]]
Rotations:-87
Matrix: [[6,10,19,10],[19,8,19,7],[9,17,19,0],[15,16,17,11]]
Output: [[15,9,19,6],[16,17,8,10],[17,19,19,19],[11,0,7,10]]