Java-使用另一个类创建构造函数类';s参数
我很难实现这个类 我需要创建一个类public CombineTopBottom(图顶、图底、int animationType)表示通过将两个图放置在彼此的顶部而创建的图。该类依赖于TwoDimArrayUtil.appendTopBottom()方法,实现图接口并定义两个实例变量:一个跟踪动画类型的整数和一个表示图(板)的二维字符数组 这是一个构造函数,它使用提供的参数值初始化animationType,并使用调用与顶部和底部图表关联的板上的TwoDimArrayUtil.appendTopBottom()生成的图表初始化板。 参数: 顶- 底部- 动画类型- 抛出: java.lang.IllegalArgumentException-如果顶部和底部图表的列数不同。任何错误消息都可以 这是TwoDimArrayUtil.appendTopBottom()方法,后面是图表接口,后面是我到目前为止为CombineTopBottom类所做的工作。 提前谢谢你Java-使用另一个类创建构造函数类';s参数,java,Java,我很难实现这个类 我需要创建一个类public CombineTopBottom(图顶、图底、int animationType)表示通过将两个图放置在彼此的顶部而创建的图。该类依赖于TwoDimArrayUtil.appendTopBottom()方法,实现图接口并定义两个实例变量:一个跟踪动画类型的整数和一个表示图(板)的二维字符数组 这是一个构造函数,它使用提供的参数值初始化animationType,并使用调用与顶部和底部图表关联的板上的TwoDimArrayUtil.appendTo
public static char[][] appendTopBottom(char[][] top, char[][] bottom) {
int numRows = top.length + bottom.length;
int numCols = (top[0].length > bottom[0].length) ? top[0].length : bottom[0].length;
System.out.println(" Rows " + numRows + " Cols " + numCols);
char[][] retArray = new char[numRows][numCols];
TwoDimArrayUtil.toString(top);
TwoDimArrayUtil.toString(bottom);
TwoDimArrayUtil.toString(retArray);
TwoDimArrayUtil.copyArray(retArray, top, 0, 0);
TwoDimArrayUtil.copyArray(retArray, bottom, top.length, 0);
return retArray;
}
/**
* Interface implemented by any class representing a Diagram. A diagram is
* defined by a two-dimensional array of characters (board), where each
* character represents a color. Colors: Red ('R'), Green ('G'), Blue ('B'),
* Yellow ('Y'), Black ('*'), White ('.').
*/
public interface Diagram {
/**
* Returns a two-dimensional array of characters representing a diagram.
*
* @return
*/
public char[][] getBoard();
/**
* Returns the next two-dimensional array of characters to display during an
* animation.
*
* @return
*/
public char[][] nextAnimationStep();
/**
* Number of rows associated with the diagram.
*
* @return
*/
public int getNumberRows();
/**
* Number of columns associated with the diagram.
*
* @return
*/
public int getNumberCols();
}
public CombineLeftRight(Diagram left, Diagram right, int animationType) {
this.animationType = animationType;