package Lect29Library; /** * This class implements the data component of the MVC associated * with a textEditor. The text area is represented as a two-dimensional * array of characters. */ public class TextEditorCorrect { private int numLines; private char[][] textArea; public TextEditorCorrect() { // no lines to start textArea = new char[0][]; numLines = 0; } public void deleteLine(int lineNum) { int row; // shift elements up for (row=lineNum; rowlineNum; row--){ textArea[row] = textArea[row-1]; } // insert line textArea[lineNum] = line; } else { // no space therefore we expand array // new array to fit the new line char[][] newTextArea; newTextArea = new char[textArea.length + 1][]; // copy current lines to new array and insert line for (int row=0,newRow=0; row