У меня проблемы с реализацией этого класса.
Мне нужно создать класс publi c CombineTopBottom (Diagram top, Diagram bottom, int animationType), который представляет диаграмму, созданную путем размещения двух диаграмм на друг на друга Класс основан на методе TwoDimArrayUtil.appendTopBottom (), реализует интерфейс Diagram и определяет две переменные экземпляра: целое число, которое отслеживает тип анимации, и двумерный массив символов, представляющих диаграмму (доску).
Это конструктор, который инициализирует animationType с предоставленным значением параметра и инициализирует плату с диаграммой, полученной в результате вызова TwoDimArrayUtil.appendTopBottom () для плат, связанных с верхней и нижней диаграммами. Параметры: top - bottom - animationType - Throws: java .lang.IllegalArgumentException - если количество столбцов верхней и нижней диаграмм различно. Любое сообщение об ошибке в порядке.
Это метод TwoDimArrayUtil.appendTopBottom (), за которым следует интерфейс Diagram, за которым следует то, что я до сих пор использовал для класса CombineTopBottom. Заранее спасибо!
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;