-
Notifications
You must be signed in to change notification settings - Fork 0
/
FlyList.cpp
54 lines (45 loc) · 1.32 KB
/
FlyList.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// FlyList.cpp: implementation of the CFlyList class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "whitefly.h"
#include "FlyList.h"
#include <float.h>
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
double CFlyList::GetQuantity( double MinAge)
{
// Returns the number of flys in the list that are older than
// MinAge. Note the default value for MinAge is -1 which returns
// the quantity of all flys in the list
double TotalCount = 0.0;
POSITION pos = GetHeadPosition();
while (pos != NULL)
{
CInsect* theFly = (CInsect*)GetNext(pos);
if (theFly->GetAge()>= MinAge) TotalCount += theFly->GetQuantity();
}
return TotalCount;
}
CInsect* CFlyList::RemoveMatures()
{
// Removes the tail and returns it if the age of that boxcar is >= Maximum Age
// If the age is not not >= Maximum, NULL is returned
if (IsEmpty()) return NULL;
else
{
CInsect* theFly = (CInsect*)GetTail();
if (theFly->GetAge() >= m_MaxAgeDD)
{
theFly = (CInsect*)RemoveTail();
}
else theFly = NULL;
return theFly;
}
}