Question

In: Computer Science

First, create a class object named SequenceMap that has as private data members the following two:...

First, create a class object named SequenceMap that has as private data members the following two:

string recognition_sequence_ ;

vector enzyme_acronyms_;

Other than the big-five (note that you can use the defaults for all of them), you have to add the following:

a) A constructor SequenceMap(const string &a_rec_seq, const string &an_enz_acro),that constructs a SequenceMap from two strings (note that now the vector enzyme_acronyms_ will contain just one element, the an_enz_acro).

b) bool operator<(const SequenceMap &rhs) const, that operates based on the regular string comparison between the recognition_sequence_ strings (this will be a one line function).

c) Overload the operator<< for SequenceMap.

d) void Merge(const SequenceMap &other_sequence). This function assumes that the object’s recognition_sequence_ and other_sequence.recognition_sequence_ are equal to each other. The function Merge() merges the other_sequence.enzyme_acronym_ with the object’s enzyme_acronym_. The other_sequence object will not be affected.

Please test it with your own test functions to make sure that it operates correctly.

Please also show the test functions that you utilize so I can also implement it.

thank you.

Solutions

Expert Solution

SequenceMap.cpp

#include "SequenceMap.h"

int main() {
   string recSequence = "SEQUENCE";
   string recSequence_ = "SEQUENCE_";
   string enzymeOne = "enzymeOne";
   string thingS = "THINGS";
   string enzymeThree = "enzymeThree";
   SequenceMap mySM(recSequence, enzymeOne);
   SequenceMap anotherSM(recSequence, enzymeThree);
   SequenceMap diffSM(thingS, thingS);
   if (mySM < diffSM) {
       cout << "it is true" << endl;
   }
   else {
       cout << "it is false" << endl;
   }
   //cout << mySM;
   mySM.Merge(diffSM);
   mySM.Merge(anotherSM);

   cout << "###############" << endl;
   cout << mySM;
   //*/
   return 0;
}

SequenceMap.h

#ifndef SEQUENCEMAP_H
#define SEQUENCEMAP_H

#include <iostream>
#include <string>
#include <vector>
using namespace std;

class SequenceMap {
public:
   // Zero-parameter constructor.
    SequenceMap() = default;
    // Copy-constructor.
    SequenceMap(const SequenceMap &rhs) = default;
    // Copy-assignment.
    SequenceMap& operator=(const SequenceMap &rhs) = default;
    // Move-constructor.
   SequenceMap(SequenceMap &&rhs) = default;
   // Move-assignment.
   SequenceMap& operator=(SequenceMap &&rhs) = default;
   // Destructor.
   ~SequenceMap() = default;

   // Start of Part 1

   // Constructor for recognition sequence and enzyme acronym
   SequenceMap(const string &a_rec_seq, const string &an_enz_acro) {
       recognition_sequence_ = a_rec_seq;
       enzyme_acronyms_.push_back(an_enz_acro);
   }

   // Constructor for recognition sequence only
   SequenceMap(const string &a_rec_seq) {
       recognition_sequence_ = a_rec_seq;
       enzyme_acronyms_.push_back("");
   }

   // Overload the < operator
   bool operator<(const SequenceMap &rhs) const {
       return (recognition_sequence_ < rhs.recognition_sequence_);
   }

   // Overload the << operator to print the recognition sequence with enzyme acronyms
   friend std::ostream &operator<<(std::ostream &out, const SequenceMap &a_SequenceMap) {
       out << a_SequenceMap.recognition_sequence_ << "   ";
       for (int i = 0; i < a_SequenceMap.enzyme_acronyms_.size(); ++i) {
           out << a_SequenceMap.enzyme_acronyms_[i] << " ";
       }
       return out;
   }

   // Merge two SequenceMap objects
   void Merge(const SequenceMap &other_sequence) {
       for (int i = 0; i < other_sequence.enzyme_acronyms_.size(); ++i) {
           enzyme_acronyms_.push_back(other_sequence.enzyme_acronyms_[i]);  
       }
   }

   // Print the recognition sequence
   string getRecognitionSequence() const {
       return recognition_sequence_;
   }

   // Print enzyme acronym
   void printAllEnzAcroOfRecSeq() const {
       for (int i = 0; i < enzyme_acronyms_.size() ; ++i) {
           cout << enzyme_acronyms_[i] << "   ";  
       }
       cout << endl;
   }


private:
   string recognition_sequence_ ;
   vector<string> enzyme_acronyms_;
};

#endif


Related Solutions

Part 1 Create a class named Room which has two private data members which are doubles...
Part 1 Create a class named Room which has two private data members which are doubles named length and width. The class has five functions: a constructor which sets the length and width, a default constructor which sets the length to 12 and the width to 14, an output function, a function to calculate the area of the room and a function to calculate the parameter. Also include a friend function which adds two objects of the room class. Part...
The Account class Create a class named Account, which has the following private properties:
in java The Account class Create a class named Account, which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNumber (), getBalance (), setBalan newBalance). There is no setNumber () once an account is created, its account number cannot change. Now implement these methods: void deposit (double amount) and void withdraw (double amount). For both these methods, if the amount is less than...
The Account class Create a class named Account , which has the following private properties:
 The Account class Create a class named Account , which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNunber(), getBalance(), setBalance (double newBalance) . There is no setNunber() - once an account is created, its account number cannot change. Now implement these methods: void deposit (double anount) and void withdraw(double anount). For both these methods, if the amount is less than zero,...
WRITE IN C++ Create a class named Coord in C++ Class has 3 private data items...
WRITE IN C++ Create a class named Coord in C++ Class has 3 private data items               int xCoord;               int yCoord;               int zCoord; write the setters and getters. They should be inline functions               void setXCoord(int)             void setYCoord(int)            void setZCoord(int)               int getXCoord()                     int getYCoord()                   int getZCoord() write a member function named void display() that displays the data items in the following format      blank line      xCoord is                          ????????      yCoord is                          ????????      zCoord...
Define the class HotelRoom. The class has the following private data members: the room number (an...
Define the class HotelRoom. The class has the following private data members: the room number (an integer) and daily rate (a double). Include a default constructor as well as a constructor with two parameters to initialize the room number and the room’s daily rate. The class should have get/set functions for all its private data members [20pts]. The constructors and the get/set functions must throw an invalid_argument exception if either one of the parameter values are negative. The exception handler...
Define the class HotelRoom. The class has the following private data members: the room number (an...
Define the class HotelRoom. The class has the following private data members: the room number (an integer) and daily rate (a double). Include a default constructor as well as a constructor with two parameters to initialize the room number and the room’s daily rate. The class should have get/set functions for all its private data members [20pts]. The constructors and the get/set functions must throw an invalid_argument exception if either one of the parameter values are negative. The exception handler...
object oriented programming java Create a Student class that have two data members id (assign to...
object oriented programming java Create a Student class that have two data members id (assign to your ID) and name (assign to your name). Create the object of the Student class by new keyword and printing the objects value. You may name your object as Student1. The output should be like this: 20170500 Asma Zubaida
Create a class called Car (Car.java). It should have the following private data members: • String...
Create a class called Car (Car.java). It should have the following private data members: • String make • String model • int year Provide the following methods: • default constructor (set make and model to an empty string, and set year to 0) • non-default constructor Car(String make, String model, int year) • getters and setters for the three data members • method print() prints the Car object’s information, formatted as follows: Make: Toyota Model: 4Runner Year: 2010 public class...
Create a class called Car (Car.java). It should have the following private data members: • String...
Create a class called Car (Car.java). It should have the following private data members: • String make • String model • int year Provide the following methods: • default constructor (set make and model to an empty string, and set year to 0) • non-default constructor Car(String make, String model, int year) • getters and setters for the three data members • method print() prints the Car object’s information, formatted as follows: Make: Toyota Model: 4Runner Year: 2010 public class...
This should be written in C++. Create a class with the name "Student". private data members...
This should be written in C++. Create a class with the name "Student". private data members of the Student class should include: int - rollno (roll number or id number of student) string - name (name of student) int - alg, datastruct, architect, proglang (hold scores out of 100 for these 4 classes) float - per (average score of 4 classes above) char - grade (letter grade based on per.. example 90 is an A) public member functions of the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT