Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HERE IS A LINK WHERE YOU CAN FIND THE STD.JAR LIBRARIES. ITS UNDER THE NAME 'Linux-based Virtual Machine' AND SAYS IO LIBRARIES. https://www.swamiiyer.net/cs210/course_info.html here is

image text in transcribed

HERE IS A LINK WHERE YOU CAN FIND THE STD.JAR LIBRARIES. ITS UNDER THE NAME 'Linux-based Virtual Machine' AND SAYS IO LIBRARIES.

https://www.swamiiyer.net/cs210/course_info.html

here is the code template, please follow:

package edu.umb.cs210.p2; import dsa.LinkedStack; import stdlib.StdOut; // A data type representing a text editor buffer. public class Buffer { protected LinkedStack left; // chars left of cursor protected LinkedStack right; // chars right of cursor // Create an empty buffer. public Buffer() { ... } // Insert c at the cursor position. public void insert(char c) { ... } // Delete and return the character at the cursor. public char delete() { ... } // Move the cursor k positions to the left. public void left(int k) { ... } // Move the cursor k positions to the right. public void right(int k) { ... } // Return the number of characters in the buffer. public int size() { ... } // Return a string representation of the buffer with // a "|" character (not part of the buffer) at the // cursor position. public String toString() { StringBuilder sb = new StringBuilder(); // Push chars from left into a temporary stack. ... // Append chars from temporary stack to sb. ... // Append "|" to sb. ... // Append chars from right to sb. ... // Return the string from sb. ... } // Test client (DO NOT EDIT). public static void main(String[] args) { Buffer buf = new Buffer(); String s = "There is grandeur in this view of life, " + "with its several powers, having been originally " + "breathed into a few forms or into one; and that, " + "whilst this planet has gone cycling on according " + "to the fixed law of gravity, from so simple a " + "beginning endless forms most beautiful and most " + "wonderful have been, and are being, evolved. ~ " + "Charles Darwin, The Origin of Species"; for (int i = 0; i   Exercise 4. (Text Editor Buffer) Develop a data type Buffer for a buffer in a text editor that implements the following API: Method Buffer char delete() void left(int k) Description creates an empty buffer inserts c at the cursor position deletes and returns the character at the cursor moves the cursor k positions to the left moves the cursor k positions to the right returns the number of characters in the buffer returns a string representation of the buffer with a part of the buffer) at the cursor position void right(int k) int size) String toString() character (not >- */workspace/project2 $ java edu.umb. cs 210.p2. Buffer I There is grandeur in this view of life, with its several powers, having been originally breathed by the Creator into a few forms or into one; and that, whilst this planet has gone cycling on according to the fixed law of gravity, from so simple a beginning endless forms most beautiful and most wonderful have been, and are being, evolved. -- Charles Darwin, The Origin of Species Hint: Use two stacks left and right to store the characters to the left and right of the cursor, with the characters on top of the stacks being the ones immediately to its left and right.  Exercise 4. (Text Editor Buffer) Develop a data type Buffer for a buffer in a text editor that implements the following API: Method Buffer char delete() void left(int k) Description creates an empty buffer inserts c at the cursor position deletes and returns the character at the cursor moves the cursor k positions to the left moves the cursor k positions to the right returns the number of characters in the buffer returns a string representation of the buffer with a part of the buffer) at the cursor position void right(int k) int size) String toString() character (not >- */workspace/project2 $ java edu.umb. cs 210.p2. Buffer I There is grandeur in this view of life, with its several powers, having been originally breathed by the Creator into a few forms or into one; and that, whilst this planet has gone cycling on according to the fixed law of gravity, from so simple a beginning endless forms most beautiful and most wonderful have been, and are being, evolved. -- Charles Darwin, The Origin of Species Hint: Use two stacks left and right to store the characters to the left and right of the cursor, with the characters on top of the stacks being the ones immediately to its left and right

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions