Question: Please write this code for me . i neeed it in java and makw sure you dont change any of the codee already given and
Please write this code for me i neeed it in java and makw sure you dont change any of the codee already given and implement all the classes and dont remove any of the classes. tysm
this is the editor.java
package Editor;
import java.ioBufferedReader;
import java.ioBufferedWriter;
import java.ioIOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import MyImplementations.MyArrayList;
import MyImplementations.MyStack;
import MyImplementations.MyString;
public class Editor
cursor row position
int row;
cursor column position
int col;
the text of the editor
MyArrayList text;
the undo stack
MyStack undoStack;
the redo stack
MyStack redoStack;
Current file name
MyString fileName;
class EditorAction
the row of the action
int row;
the column of the action
int col;
the text of the action
MyString text;
the length of the action
int length;
the action type
ActionType type;
enum ActionType
insert action
INSERT,
delete action
DELETE,
replace action
REPLACE
Constructor
public EditorString myFilename
thisnew MyStringmyFilename;
public EditorMyString fileName
this.fileName fileName;
undoStack new MyStack;
redoStack new MyStack;
openfileName;
Open the file with the given name and read the contents into the editor.
void openString fileName
opennew MyStringfileName;
void openMyString fileName
read the file into the text
set the cursor to the beginning of the file
set the file name
WRITE YOUR CODE HERE
Save the current text to currently open file.
void save
saveAsfileName;
Save the current text to the given file.
void saveAsString fileName
saveAsnew MyStringfileName;
void saveAsMyString fileName
WRITE YOUR CODE HERE
Undo the last action.
void undo
WRITE YOUR CODE HERE
Redo the last undone action.
void redo
WRITE YOUR CODE HERE
Save the state of the EditorAction and push it onto the undo stack. used by insert and delete
@param type
@param s
void saveStateActionType type, MyString s
WRITE YOUR CODE HERE
Save the state of the EditorAction and push it onto the undo stack. used by replace
@param type
@param s
@param length
void saveStateActionType type, MyString s int length
WRITE YOUR CODE HERE
Insert the given string at the current cursor position.
The cursor position is updated to point to the end of the inserted string.
void insertString s
insertnew MyStrings;
void insertMyString s
inserts true;
void insertMyString s boolean saveState
WRITE YOUR CODE HERE
void deleteint n
deleten true;
Delete n characters at the current cursor position.
The cursor position is updated to point to the end of the deleted string.
void deleteint n boolean saveState
WRITE YOUR CODE HERE
Replace the character at the current cursor position with the given
character.
The cursor position is updated to point to the end of the deleted string.
void replaceint n String s
replacen new MyStrings;
void replaceint n MyString s
replacen s true;
Replace the n characters at the current cursor position with the given string.
The cursor position is updated to point to the end of the replaced string.
void replaceint n MyString s boolean saveState
WRITE YOUR CODE HERE
Find the first instance of given string in the editor and set the cursor to
that position.
int findString s
return findnew MyStrings;
int findMyString s
WRITE YOUR CODE HERE
return null;
Move the cursor to the given position.
void moveCursorint row, int col
WRITE YOUR CODE HERE
Return the current cursor position.
int getCursor
return new introw col;
Move the cursor to the given position.
void moveCursorint rowcol
WRITE YOUR CODE HERE
return the entire line in row
MyString getTextint row
return text.getrow;
return the line in row from col to the end
MyString getTextint row, int col
WRITE YOUR CODE HERE
return the line from col to n character length
MyString getTextint row, int col, int n
WRITE YOUR CODE HERE
Implement Undo Redo
Implement Undo Redo
undo
Redo
saveState
Review the contents of Editor.java and TestEditor.java under Editor
directory to understand the requirements.
Use terminal to compile and run the program.
Manually Check to see if the files AntiHeros.txt and
AntiHerosViaUndo.txt are the same
Manually Check to see if the files Jokers.txt and JokersViaRedo.txt are
the same.
Editortest
assert editorgetTextequalsJokers;
editor.save;
Saveas AntiHerosViaUndo.txt
editor.saveAsAntiHerosViaUndotxt;
undo
editor.undo;
asserteditorgetTextequalsAntiHeros;
editor.undo;
asserteditorg
public c
assert editorgetText
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
