[SOLVED] COSC2436 Programming Fundamentals III Lab 2

25.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

5/5 - (3 votes)

Do the following exercise from the book. Follow the instructions for all assignments (one link up) and any specific additional instructions for each problem.

Ch. 4, Programming Problem 8, pg. 157

Specify and implement an ADT character string by using a linked chain of characters. Include typical operations such as finding its length, appending one string to another, finding the index of the leftmost occurrence of a character in a string, and testing whether one string is a substring of another. Program must compile and run.

Name the program charchain.cpp. Make sure the following requirements are met.

  • Program must compile and run.
  • Create an ADT character string as a class (LinkedChar is name I am using) that uses a linked list of each character. Do not use any STL container for the internal data structure.
  • The LinkedChar class minimally has the methods in the UML diagram below. You can add more methods.
  • Main function will have a menu of options.
  • Enter new string and store as linked list of characters in an ADT LinkedChar class
  • Get current length (number of characters stored) from the LinkedChar
  • Find index of character in this LinkedChar
  • Append another LinkedChar to this LinkedChar
  • Test if another LinkedChar is submatch of this LinkedChar
  • Quit

Example UML Class Diagram (missing attributes)

LinkedChar
LinkedChar();c
LinkedChar(const std::string s);
int length() const;
int index(char ch) const; // -1 if no match
void append(const LinkedChar& lc);
bool submatch(const LinkedChar& lc) const;

Remember to upload all files before submitting.

charchain.cpp

Textbook:

Data Abstraction and Problem Solving with C++, Frank M. Carrano, ISBN 978-0-13-446397-1

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.