DNA-sim

git clone git://git.codymlewis.com/DNA-sim.git
Log | Files | Refs | README | LICENSE

Codon.cpp (973B)


      1 /**
      2  * Codon.cpp - DNA_sim
      3  * Author: Cody Lewis
      4  * Date: 2018-07-07
      5  * Last Modified: 2018-07-07
      6  * Description:
      7  *  A Class for A codon (a collection of three mRNA bases)
      8  */
      9 #include <cstdlib>
     10 #include "Codon.h"
     11 namespace DNA_sim {
     12   // Constructors
     13   Codon::Codon() {
     14     bases.resize(3);
     15   }
     16   Codon::Codon(std::string input) {
     17     Codon();
     18     set_bases(input);
     19   }
     20   // Destructor
     21   Codon::~Codon() {}
     22   // Queries
     23   std::string Codon::get_bases() const {
     24     return bases;
     25   }
     26   // Mutators
     27   bool Codon::set_bases(std::string input) {
     28     bases = input;
     29     return true;
     30   }
     31   // Operator overloads
     32   std::istream& operator>>(std::istream& in, Codon& cod) {
     33     std::string input;
     34     in >> input;
     35     cod.set_bases(input);
     36     return in;
     37   }
     38   std::ostream& operator<<(std::ostream& out, const Codon& cod) {
     39     out << cod.get_bases();
     40     return out;
     41   }
     42   bool operator<(const Codon& lhs, const Codon& rhs) {
     43     return lhs.get_bases() < rhs.get_bases();
     44   }
     45 }