Question: Write a class called StringCode with the following functions. (Do not change these function names or return types, else the tests will fail). public static

 Write a class called StringCode with the following functions. (Do not

Write a class called StringCode with the following functions. (Do not change these function names or return types, else the tests will fail). public static String blowup(String str) Returns a version of the original string as follows: each digit 0-9 that appears in the original string is replaced by that many occurrences of the character to the right of the digit. So the string "a3tx2z yields "attttxzzz", and "12x" yields "2xxx". A digit not followed by a character (i.e. at the end of the string) is replaced by nothing (Keep the digit as is). public static int maxRun(String str) Given a string, returns the length of the largest run in the string. A "run" is a series of zero or more adjacent characters that are the same. So the max run of "xxyyyz" is 3, and the max run of "xyz" is 1. A junit test for the Matrix class has been provided under Files rightarrow Homework rightarrow HW01. Your class must pass all the tests in that file. Import static org.junit.Assert.*: import org.junit.Test: import java.util.*: /* EmailsTest - unit tests for the Emails class. */ public class MatrixTest { // Matrix Create @Test public void testMatrixCreate() { Matrix m = new Matrix(10, 4): assertEquals(10,m.getrow()): } @Test public void testMatrixString() { Matrix m = new Matrix(10, 4): m.setValueAt (0, 0, 10): m.setValueAt (0, 0, -10): System.out.println(m): } @Test public void testValueSet() { Matrix m = new Matrix(10, 4): m.setValueAt (0, 0, 10): m.setValueAt (0, 0, -10): assertEquals (10, m.getValueAt(0, 0)): } public void testAdd() { Matrix m1 = new Matrix (10, 4): m1.setValueAt(0, 0, 10): matrix m2 = new Matrix(10, 4): m2.setValueAt (0, 0, 10): Matrix m = Matrix.add(m1, m2): assertEquals (20, m.getValueAt(0, 0)): } @Test public void testMultiply() { Matrix m = new Matrix(10, 4): m.setValueAt(0, 0, 10): Matrix m1 = m.multiply(2): assertEquals(20, m1.getValueAt(0, 0)): } @Test public void testGetDiagonalSum() { Matrix m = new Matrix (10, 10): m.setValueAt (0, 0, 10): m.setValueAt(1, 1, -10): assertEquals (0, m.getDiagonalSum()): } }

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!