Question: Implement the following Edit Operations insert delete find getCursor - get the current row and col of the cursor position moveCursor - place the cursor

Implement the following Edit Operations
insert
delete
find
getCursor - get the current row and col of the cursor position
moveCursor - place the cursor at the given row and col
replace
im getting these errors:
LAST RUN on 11/21/2024,11:45:55 PM
{"error": "Pre command failed:
MyImplementations/MyArrayList.java:3: error: MyArrayList is not abstract and does not override abstract method set(int,E) in MyList
public class MyArrayList implements MyList {
^
where E is a type-variable:
E extends Object declared in class MyArrayList
MyImplementations/TestMyString.java:24: error: cannot find symbol
System.out.println(\"s1 indexOf 'o' is \"+ s1.indexOf('o'));
^
symbol: method indexOf(char)
location: variable s1 of type MyString
MyImplementations/TestMyString.java:25: error: cannot find symbol
System.out.println(\"s1 indexOf \\\"o J\\\" is \"+ s1.indexOf(\"o J\"));
^
symbol: method indexOf(String)
location: variable s1 of type MyString
MyImplementations/TestMyString.java:27: error: cannot find symbol
System.out.println(\"s2 replace 'm' with '$' is \"+ s2.replace('m','$'));
^
symbol: method replace(char,char)
location: variable s2 of type MyString
MyImplementations/TestMyString.java:28: error: cannot find symbol
System.out.println(\"s1 replace \\\"o Java\\\" with \\\"o C#\\\" is \"+ s1.replace(\"o Java\",\"o C#\"));
^
symbol: method replace(String,String)
location: variable s1 of type MyString
MyImplementations/TestMyString.java:31: error: cannot find symbol
System.out.println(\"s1 count 'o' is \"+ s1.count('o'));
^
symbol: method count(char)
location: variable s1 of type MyString
MyImplementations/TestMyString.jav
}
}
public class MyString {
private char[] chars;
public MyString(char[] chars){
this.chars = chars.clone();
}
public MyString(String s){
this(s.toCharArray());
}
public int length(){
return chars.length;
}
public char charAt(int index){
if (index 0|| index >= chars.length) throw new IndexOutOfBoundsException();
return chars[index];
}
public MyString substring(int begin, int end){
if (begin 0|| end > chars.length || begin > end) throw new IndexOutOfBoundsException()
char[] subChars = new char[end - begin];
System.arraycopy(chars, begin, subChars, 0, end - begin);
return new MyString(subChars);
}
public MyString concat(MyString s){
char[] result = new char[chars.length + s.length()];
System.arraycopy(chars,0, result, 0, chars.length);
System.arraycopy(s.chars, 0, result, chars.length, s.length());
return new MyString(result);
}
public String toString(){
return new String(chars);
}
}
size
Aa ab -*? of 6
1 package MyImplementations;
public class MyStack {
private MyArrayList list = new MyArrayList>();
public boolean isEmpty(){
return list.size()==0;
}
public void push(E e){
list.add(list.size(), e);
}
public E pop(){
if (isEmpty()) throw new IllegalStateException("Stack is empty");
return list.remove(list.size()-1);
}
public E peek(){
if (isEmpty()) throw new IllegalStateException("Stack is empty");
return list.get(list.size()-1);
}
public int getSize(){
return list.size();
}
@Override
public String toString(){
return "Stack: "+ list.toString();
}
}
```
package MyImplementations;
public class MyArrayList implements MyList {
public static final int INITIAL_CAPACITY =16;
@SuppressWarnings("unchecked")
private E[] data =(E[]) new Object[INITIAL_CAPACITY];
private int size =- ;
public MyArrayList(){}
@SuppressWarnings("unchecked")
public MyArrayList(int capacity){
data =(E[]) new Object[capacity];
}
public MyArrayList(E[] objects){
for (E obj : objects){
add(size, obj);
}
}
@Override
public void add(int index, E e){
if (index 0|| index > size) throw new IndexOutOfBoundsException();
ensureCapacity();
for (int i = size -1; i >= index; i--){
data[i +1]= data[i];
}
data[index]= e;
size++;
}
private void ensureCapacity(){
if (size >= data.length){
@SuppressWarnings("unchecked")
E[] newData =(E[]) new Object[data.length *2+1];
System.arraycopy(data,0, newData, 0, size);
data = newData;
}
}
@Override
public E get(int index){
```
```
if (index 0|| index >= size) throw new IndexOutOfBoundsException();
return data[index];
}
@Override
public int indexOf(Object e){
for (int i =0; i size; i++){
if (e == null ? data[i]== null : e.equals(data[i])) return i;
}
return -1;
}
@Override
public int lastIndexOf(E e){
for (int i = size -1; i >=0; i--){
if (e == null ? data[i]== null : e.equals(data[i])) return i;
}
return -1;
}
@Override
public E remove(int index){
if (index 0|| index >= size) throw new IndexOutOfBoundsException();
E removed = data[index];
for (int i = index; i size -1; i++){
data[i]= data[i +1];
}
data[size -1]= null;
size--;
return removed;
}
@Override
public E set(int index, E e){
if (index 0|| index >= size) throw new IndexOutOfBoundsException();
E old = data[index];
data[index]= e;
return old;
}
@Override
public int size(){
return size;
}
@Override
public void
Implement the following Edit Operations insert

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!