Objective: The main objective of this assignment is to prepare students for the final project. The students will need to implement a program that involves two ADTs and communication among them....

C++ Assignment


Objective: The main objective of this assignment is to prepare students for the final project. The students will need to implement a program that involves two ADTs and communication among them. Description: You will need to create a simple ADT called Buffer, which allows users to write and edit “text”, and another ADT called Interpreter, to interpret the user’s commands (insert text, delete text, and append text) and invoke the Buffer’s appropriate methods to complete those actions. Note: If you are interested in more robust approaches for data structures that hold text buffers, check Ropes and Gap Buffers, which are used in real open source and commercial software. Task 1 - Create the Buffer ADT 1. The text must be stored in a dynamic array of characters. This array will be expanding when inserting/appending text and shrinking when deleting text. 2. A variable to indicate the index position of a cursor 3. Constructor/Destructor 4. Delete: Deletes “n” characters starting from some index “i”. Even when deleting all characters, a single empty char will remain in the buffer to allow further actions. Similarly, your program should not allow the last empty character to be deleted. 5. Append: Add text at the end of the buffer’s dynamic character array, leaves empty character at end of buffer. 6. Insert: text to add, index position of where to add. Note that we never replace or delete content when using the “insert operation”. Thus, in Figure 1, if we insert text at index 4, the ‘o’ will not be deleted but shifted to the right. 7. Print Buffer (Figure 1) Print the character array and the indices on top to make inserting and deleting easier Print the size of the buffer Add “^” below the position of the cursor Print the index of the cursor The buffer must be automatically initialized with the text “Hello World! “ note the trailing empty character Figure 1 Cursor The cursor indicates where text can be appended and thus it always points to the end of the buffer. Task 2 - Create the Interpreter ADT This ADT must provide access to the Buffer’s methods via a Menu as indicated in Figure 2. Figure 2 1. The interpreter must not contain Buffer as an attribute, use a pointer variable to the Buffer instead as a private attribute 2. Constructor 3. Must not allow illegal input i.e. inserting at invalid index, deleting characters that are not there, etc. You are free to design the rest of the program in any manner as long as the requirements are met. Additional Requirements 1. Separate header and source files for the two ADTs. 2. No memory leaks must be present (delete arrays that are not needed). 3. After selecting action, the user should be able to cancel before supplying required info (where to insert, what to delete, etc.) 4. The menu should include an exit option Grading Rubric Total Points: 100 Points Allotted: · Compilation30 · Correct Number of files10 · Appropriate Public and Private sections10 · Append10 · Insert10 · Delete10 · No memory leaks10 · Menu10 Submission notes: · Zip the entire Code::Blocks project containing all the .cpp, .h, .cbp files name the zipped file “Assg8_cslogin.zip”, where the cslogin is your login ID for the computers at the Department of Computer Science at ODU. · Submit the zipped file using the appropriate Blackboard link. Sample Output Figure 3 Before Append Figure 4 After Append Figure 5 Before Delete Figure 6 After Delete
Nov 12, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here