Question
use java 1 You are to implement an Editor class implementing the EditorInterface. In addition to the methods in the EditorInterface, implement a default constructor
use java
1 You are to implement an Editor class implementing the EditorInterface. In addition to the methods in the EditorInterface, implement a default constructor that initializes the editor with empty content.
The OutOfBoundsException should be an unchecked exception.
public interface EditorInterface { // inserts the ch at the location loc. // If the length of the document in the editor is smaller than loc, // raise an OutOfBoundsException void insert(int loc, char ch);
// removes the character at location loc. If the length of the document // is smaller than loc - 1, raise an OutOfBoundsException // returns the character at loc before the remove operation // the message for OutOfBoundsException is "OutOfBoundException: " + loc char remove(int loc);
// returns the content in the editor String getContent();
// returns the size of the document in the editor int size();
}
2
Implement a Logger class that has the following methods:
- A default constructor creating an empty logger.
- int put(String element): put the element into the logger and record its sequence number. The sequence number should stay the same for the entry.
- List get(String element): retrieve the sequence numbers for each occurrence of the string in the logger. The sequence for this logger starts at 1.
- int size(): number of entries in the logger.
- int reset(): resets the logger, empties the entries and sets the start sequence to 1. Returns the number of entries before the reset.
Try to come up with an interface definition LoggerInterface for this class and then implements your interface.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started