Question
Please help Im working on an assignment for c++ in which im pretty lost are teacher wants us to: Create a class Blister that is
Please help Im working on an assignment for c++ in which im pretty lost are teacher wants us to:
Create a class Blister that is a linked-list implementation of a structure that stores and compares base-sequences. It should implement the header file Blister.h provided, without alteration. Bases are stored as characters. It should use a singly-linked linked list, with all operations running in linear time. The operations are:
The constructor takes a string and creates a linked list with those characters in order (first char in first node).
The destructor should free up newed memory.
The stream insertion operator should output the sequence.
The length member function returns the number of bases in the sequence.
The isSubstitutionOf member function compares two base-sequences and returns true if they have the same length and differ in exactly one base.
The isInsertionOf member function compares two base-sequences and returns true if the one it is called on is obtained by adding exactly one base to the other base-sequence. For example, MADAM is insertion-of MAAM as well as ADAM.
He gave us the .h file
#ifndef BLISTER_H #define BLISTER_H #includestruct Bode { const char base; Bode *next; public: Bode(char B) : base(B), next(nullptr) { } }; class Blister { private: Bode * start; public: Blister(std::string init); ~Blister( ); friend std::ostream & operator<< ( std::ostream & out, const Blister & BL); int length( ) const; bool isSubstitutionOf(const Blister & other) const; bool isInsertionOf(const Blister & other) const; }; #endif
and he also gave us the main:
#includeusing namespace std; #include "Blister.h" int main( ) { Blister X("abcde"); Blister Y("acde"); Blister Z("abode"); cout << X << " " << Y << " " << Z << endl; cout << X.length() << " " << Y.length() << " " << Z.length() << endl; cout << boolalpha << X.isSubstitutionOf(Y) << " "; cout << boolalpha << Y.isSubstitutionOf(Z) << " "; cout << boolalpha << Z.isSubstitutionOf(X) << " "; cout << endl; cout << boolalpha << Y.isInsertionOf(X) << " "; cout << boolalpha << X.isInsertionOf(Y) << " "; cout << boolalpha << Y.isInsertionOf(Z) << " "; cout << boolalpha << Z.isInsertionOf(X) << " "; cout << endl; return 0;
I need help creating a .cpp file that does these tasks
this is what i have so far
#include
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