Create a JUnit testing code titled "StudentTests to test these classes, here is the code: CombineTopBottom package system;   import java.util.Arrays;   public class CombineTopBottom implements Diagram {   privatechar[][] board; privateintanimationType;   /** * Constructor that initializes the animationType with the provided parameter * value and initializes the board with the diagram resulting from calling * TwoDimArrayUtil.appendTopBottom() on the boards associated with the top and * bottom diagrams. * * @param top the top diagram * @param bottom the bottom diagram * @param animationType the animation type * @throws IllegalArgumentException if the number of columns of the top and bottom * diagrams are different */ public CombineTopBottom(Diagram top, Diagram bottom, intanimationType) { // check if the number of columns are different if (top.getNumberCols() != bottom.getNumberCols()) { thrownew IllegalArgumentException("Number of columns are different!"); }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Create a JUnit testing code titled "StudentTests to test these classes, here is the code:

CombineTopBottom

package system;

 

import java.util.Arrays;

 

public class CombineTopBottom implements Diagram {

 

privatechar[][] board;

privateintanimationType;

 

/**

* Constructor that initializes the animationType with the provided parameter

* value and initializes the board with the diagram resulting from calling

* TwoDimArrayUtil.appendTopBottom() on the boards associated with the top and

* bottom diagrams.

*

* @param top the top diagram

* @param bottom the bottom diagram

* @param animationType the animation type

* @throws IllegalArgumentException if the number of columns of the top and bottom

* diagrams are different

*/

public CombineTopBottom(Diagram top, Diagram bottom, intanimationType) {

// check if the number of columns are different

if (top.getNumberCols() != bottom.getNumberCols()) {

thrownew IllegalArgumentException("Number of columns are different!");

}

 

this.animationType = animationType;

// append the two diagrams vertically

board = TwoDimArrayUtil.appendTopBottom(top.getBoard(), bottom.getBoard());

}

 

/**

* Returns the board.

*

* @return a two-dimensional array of characters (no need to perform a deep copy)

*/

@Override

publicchar[][] getBoard() {

returnboard;

}

 

/**

* Returns a two-dimensional array of characters representing the next animation

* step. If the animationType is 1, the board instance variable will be updated

* by rotating the board one column to the left; if the animationType is 2, the

* board instance variable will be updated by rotating the top row.

*

* @return a reference to the updated board (no need to perform a deep copy)

*/

@Override

publicchar[][] nextAnimationStep() {

if (animationType == 1) {

// rotate the board one column to the left

board = TwoDimArrayUtil.rotateLeftOneColumn(board);

} else if (animationType == 2) {

// rotate the top row of the board

board = TwoDimArrayUtil.rotateTopOneRow(board);

}

returnboard;

}

 

/**

* Returns the number of rows associated with the diagram.

*

* @return the number of rows associated with the diagram

*/

@Override

publicint getNumberRows() {

returnboard.length;

}

 

/**

* Returns the number of columns associated with the diagram.

*

* @return the number of columns associated with the diagram

*/

@Override

publicint getNumberCols() {

returnboard[0].length;

}

}

CombineLeftRight

package system;

 

import java.util.Arrays;

 

public class CombineLeftRight implements Diagram {

private Diagram left;

private Diagram right;

privateintanimationType;

privatechar[][] board;

 

/**

* Constructor that initializes the animationType with the provided parameter value and initializes

* the board with the diagram resulting from calling TwoDimArrayUtil.appendLeftRight() on the boards

* associated with the left and right diagrams.

*

* @param left diagram

* @param right diagram

* @param animationType -

* @throws IllegalArgumentException if the number of rows of the left and right diagrams are different.

* Any error message is fine.

*/

public CombineLeftRight(Diagram left, Diagram right, intanimationType) {

this.left = left;

this.right = right;

this.animationType = animationType;

 

if (left.getNumberRows() != right.getNumberRows()) {

thrownew IllegalArgumentException("The number of rows of the left and right diagrams must be equal.");

}

 

this.board = TwoDimArrayUtil.appendLeftRight(left.getBoard(), right.getBoard());

}

 

/**

* Returns the board.

*

* @return two-dimensional array of characters (no need to perform a deep copy).

*/

@Override

publicchar[][] getBoard() {

returnboard;

}

 

/**

* Returns a two-dimensional array of characters representing the next animation step.

* If the animationType is 1, the board instance variable will be updated by rotating the board

* one column to the left; if the animationType is 2, the board instance variable will be updated

* by rotating the top row.

*

* @return a reference to the updated board (no need to perform a deep copy).

*/

@Override

publicchar[][] nextAnimationStep() {

if (animationType == 1) {

board = TwoDimArrayUtil.rotateLeftOneColumn(board);

} else if (animationType == 2) {

board = TwoDimArrayUtil.rotateTopOneRow(board);

}

returnboard;

}

 

/**

* Number of rows associated with the diagram.

*

* @return the number of rows.

*/

@Override

publicint getNumberRows() {

returnboard.length;

}

 

/**

* Number of columns associated with the diagram.

*

* @return the number of columns.

*/

@Override

publicint getNumberCols() {

returnboard[0].length;

}

 

// TwoDimArrayUtil is a utility class with static methods for manipulating two-dimensional arrays.

// It is not included here for brevity.

}

 

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Adjacency Matrix
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education