Homework: Classes

  < Previous  Next >

Write your answers to the following questions in a flat text file hwkClasses.txt (not a Word document nor a Rich Text Format file):
  1. Object-oriented Programming:
    1. What are some of the benefits of encapsulation?
    2. What are the three practical rules of encapsulation?
    3. dna.cpp:
      #include "dna.h"
      
      // DNA constructor
      DNA::DNA(string label, int id, string sequence, int length, int cDNAStartIndex){
          m_Label = label;
          m_Id = id;
          m_Sequence = sequence;
          m_Length = length;
          m_CDNAStartIndex =  cDNAStartIndex;
      }
      	      
    4. As referenced in dna.cpp, m_Label must be what type of variable? (Hint: The answer is not "a string")
  2. Classes and objects:
    Write a complete (yet brief) implementation (.h & .cpp files) for a class of your choice. (Write just enough code to illustrate that you understand all the key points. For example, just have one data member.)
  3. Preprocessor/compiler directives:
    Assume that you have SequenceDatabase, DNA and DNAList classes in separate files in your project. Furthermore, the SequenceDatabase class that uses both the DNA class and the DNAList class
    and the DNAList class uses the DNA class. Write the preprocessor statement(s) that are needed in the file that has the DNA class declaration for the project to compile correctly.
  4. Namespaces:
    Write an appropriate using statement that could be used in DNA.h (above) so that the namespace of string is resolved appropriately, but without including all of the std namespace (i.e., do not use "using namespace std;").

Submission

Submit your txt file at https://3110.cs.mtsu.edu/. For further instructions, please see the Miscellaneous page.

Rubric:

Points          Item
----------      --------------------------------------------------------------
_____ /  3      1
_____ /  3      2
_____ /  1      3
_____ /  1      4
        
_____ /  8      Total
      

Last Modified: