forked from sgusev/GERMLINE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChromosomePair.cpp
36 lines (29 loc) · 897 Bytes
/
ChromosomePair.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// ChromosomePair.cpp: a pair of pointers to chromosomes
#include "ChromosomePair.h"
// ChromosomePair(): default constructor
ChromosomePair::ChromosomePair() : chrom1(NULL), chrom2(NULL)
{
}
// ChromosomePair(): constructor to create ChromosomePair from two Chromosome objects.
// Precondition: None.
// Postcondition: If the addresses of the chromosomes are not the same, then
// chrom1 points to c1 and chrom2 points to c2; otherwise a warning has been printed
// and object becomes inactive.
ChromosomePair::ChromosomePair(Chromosome &c1, Chromosome &c2)
{
activate(c1,c2);
}
// activate(): activates object
void ChromosomePair::activate(Chromosome &c1, Chromosome &c2)
{
if (&c1 != &c2)
{
chrom1 = &c1<&c2?&c1:&c2;
chrom2 = &c1<&c2?&c2:&c1;
}
else
{
cerr << "WARNING:ChromosomePair::ChromosomePair():chromosomes are the same" << endl;
}
}
// end ChromosomePair.cpp