--- /dev/null
+#ifndef __CHROMOSOME_H
+#define __CHROMOSOME_H
+
+#include <vector>
+
+#include <gene.h>
+
+using namespace std;
+
+namespace genetic {
+ template < typename _Gene >
+ class Chromosome {
+ protected:
+ vector<_Gene> genes;
+
+ public:
+ Chromosome(vector<_Gene> genes) {
+ this->genes = genes;
+ }
+
+ vector<_Gene> get() {
+ return this->genes;
+ }
+ };
+}
+
+#endif /* __CHROMOSOME_H */
\ No newline at end of file
--- /dev/null
+#ifndef __GENE_H
+#define __GENE_H
+
+namespace genetic {
+
+ template < typename Type >
+ class Gene {
+ protected:
+ Type type;
+ public:
+ Gene(Type type) {
+ this->type = type;
+ }
+
+ Type get() {
+ return this->type;
+ }
+ };
+}
+
+#endif /* __GENE_H */
\ No newline at end of file
#include <iostream>
+#include <vector>
+
+#include <cstdlib>
+
+#include "gene.h"
+#include "chromosome.h"
using namespace std;
+using namespace genetic;
int main() {
- cout << "Hello World" << endl;
+ typedef Gene<int> _Gene;
+
+ time_t t;
+ srand((unsigned)time(&t));
+
+ vector<_Gene> genes;
+
+ for (int i = 0; i < 20; i++) {
+ _Gene gene(rand() % 255);
+ cout << "Generated gene: " << gene.get() << "\n";
+ genes.push_back(gene);
+ }
+ Chromosome<_Gene> chromosome(genes);
return 0;
}
--- /dev/null
+#include <iostream>
+#include <cassert>
+
+#include "gene.h"
+#include "chromosome.h"
+
+using namespace std;
+using namespace genetic;
+
+int main() {
+ Gene<int> gene(1);
+
+ assert(gene.get() == 1);
+ cout << "Gene: " << gene.get() << " should be equal to: " << 1 << endl;
+
+ return 0;
+}
+