Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 #include  struct 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:

#include  using 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 using namespace std; #include "Blister.h" Blister::Blister(std::string init){ start = new Bode; for (int i=0; inext; start->next = nullptr; delete start; } } ostream & operator<< ( std::ostream & out, const Blister & BL) { character *next = BL.head; while(current != NULL){ out << start->symbol << ""; start = start->next; } return out; } int Blister::length( ) const{ if(head==NULL){ return 0; } return 1 + length(head->next); } bool Blister::isSubstitutionOf(const Blister & other) const{ return true } bool Blister::isInsertionOf(const Blister & other) const{ return true; }

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