C++ hw7 | Computer Science homework help

Introduction

We have discussed “inheritance”, one of the fundamental concepts of Object Oriented Programming (OOP). In this homework we will experience inheritance concept through C++ programming to reinforce what we have learned in class. We will extend Sequence class to create Gene class. We also create a driver program to test each function in Gene class.

 

Instructions: Download starter code from Learn@UW-Stout under Content (Homework). Then implement Gene.h and Gene.cpp and create a tester program.

 

In the Visual Studio project, there are three files:

·         Sequence.h: Sequence class hearder fileà no change required

·         Sequence.cpp: Sequence class implementation fileà no change required

·         GeneTest.cpp: a driver program that tests Gene class implementation

 

Sequence

          sequence: char*

          length: int

+ Sequence(string s)

+Sequence(const Sequence& s) //Copy constructor

+Sequence& operator=(const Sequence& s) //Assignment operator

+void set(int index, char c) //Set character at index to value in c

+ ~Sequence()

+ getSequence() const :char*

+ size() const :int

Friend functions

+ bool operator==(const Sequence& lhs, const Sequence&rhs)

+ostream& operator<< (ostream&ostr, constSequence&g)

+ bool operator<( const Sequence& lhs, const Sequence&rhs)

 

Gene

 

+ Gene(string s)

+Gene(const Gene& g)//Copy constructor

+Gene& operator=(const Gene& g) //Assignment operator

+ ~Gene()

+ aCount() const:int

+ cCount() const :int

+ tCount() const :int

+ gCount()const :int

For this assignment you will design a C++ class to store information about a Gene using the existing Sequence class. Starter code includes sequence class declaration (Sequence.h) and member function implementation (Sequence.cpp).

 

  • The SequenceClass:  This class simulatesa sequence in biology. 
    • Data Members
      • Array of characters for each element in the sequence. Each element is represented by a character. The array is allocated during object construction.
      • length to represent the number of elements in the Sequence.
    • Member Functions
      • Constructor that takes in a string object representing the Sequence.
        • A string object in C++ has the following useful methods:
          •  size()
          • [index] that returns the character at each index.
        • Initialize the data members using this input by determining the size of input string and then creating and filling sequence. 
      • Destructor to deallocate memory allocated by the constructor (Do last)
      • Copy Constructor
      • Assignment operator=
      • set(): void sets character at index to value in c.
      • getSequence():char* returns a pointer to the start of the sequence array.
      • size():int returns the number of elements in the sequence (chars)
    • Friend Functions
      • Operator== that returns true if the Sequences have the same size and exactly the same sequence. Note that an equal sequence could be listed in reverse order.
      • Operator<< to output the sequence with up to 40 characters per line.
      • Operator<  checks to see if the sequence on the left hand side is a subsequence of the right hand sequence. The entire subsequence must be found in the right hand sequence to be true otherwise return false. Note again that the reverse of the subsequence may be contained in the sequence.

 

 

 

  • The GeneClass:  This class should simulate a gene in biology. 
    • Member Functions
      • Constructor that takes in a string object representing the Gene.
        • Use the string to call the Sequence constructor
      • Copy Constructor (also in Sequence)
      • Assignment operator operator= (also in Sequence)
      • Destructor to deallocate memory used on the heap.
      • aCount():int returns the count of nucleotides in gene represented by a.
      • cCount():int returns the count of nucleotides in gene represented by c.
      • tCount():int returns the count of nucleotides in gene represented by t.
      • gCount():int returns the count of nucleotides in gene represented by g.

 

Must have exact method header in code as in the UML so that a different tester file can be used to grade the assignment.

 

Task #1 Coding the UML Diagrams (20 points)

 

  1. Create the header file Gene.h including all functions and data members. It will inherit from Sequence. You must use the exact names described in the UML diagram. I will provide a test file to test your code and calculate the grade.

 

  1. Create the implementation file Gene.cpp and a tester file named GeneTester.cpp.
    1. Add a single function implementation at a time.

                                                               i.      Constructor

                                                             ii.      aCount(), cCount(), tCount(), and gCount()

                                                           iii.      Destrutor

    1. After each file is implemented create an object in the main method of GeneTester to test the implementation. Be sure to test all aspects of each function thinking about boundary cases.

 

3.      After each file is implemented create an object in the main method of GeneTest to test the implementation. Be sure to test all aspects of each function.

 

Task #2 Testing

 

I will provide tester program to be downloaded from D2L. It will test your code to see that the implementations are correct. You will need to replace this tester program with yours.

 

 

Submission note: You do NOT NEED TO SUBMIT ANYTHING TO THE DROPBOX!  Instead, you will need to show your programs for your answers to the instructor or SIs during class.

 







Calculate Your Essay Price
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Order your essay today and save 10% with the coupon code: best10