HatchKeeper  0.90
The Free Open-Source Egg Incubation Software
HK_Egg.cpp
Go to the documentation of this file.
1 /*******************************************************************/
9 #include "../headers/Egg.h"
10 
13 
16 {
17  HK_DayWeight.clear();
18  HK_DayWeight.shrink_to_fit();
19  HK_DayComment.clear();
20  HK_DayComment.shrink_to_fit();
21 }
22 
24 int HK_Egg::CalcDayLoss(int Day)
25 {
26  //Make Sure Its Not Zero
27  if(HK_DayWeight[Day].IsZero())
28  return 0;
29 
30  //Find Last Day With Weight Set
31  for(int A = (Day-1); A >= 0; A--)
32  if(!HK_DayWeight[A].IsZero())
33  return HK_DayWeight[A].DiffPercent(HK_DayWeight[Day]);
34  return 0;
35 }
36 
39 {
40  //Find Last Day With Weight Set
41  for(int A = (GetDays() - 1); A > 0; A--)
42  if(!HK_DayWeight[A].IsZero())
43  return HK_DayWeight[0].DiffPercent(HK_DayWeight[A]);
44  return 0;
45 }
46 
48 string HK_Egg::GetTag1(){ return HK_Tag1;}
50 string HK_Egg::GetTag2(){ return HK_Tag2;}
52 string HK_Egg::GetTag3(){ return HK_Tag3;}
62 int HK_Egg::GetDays(){ return HK_DayComment.size();}
64 string HK_Egg::GetComments(){ return HK_Comments;}
66 vector<HK_Weight> HK_Egg::GetDayWeight(){ return HK_DayWeight;}
68 vector<string> HK_Egg::GetDayComments(){ return HK_DayComment;}
69 
71 HK_KeyValue HK_Egg::Search(string Value, string BatchName, int Egg)
72 {
73  HK_KeyValue Results;
74 
75  string Comments = HK_Comments;
76  string Tag1 = HK_Tag1;
77  string Tag2 = HK_Tag2;
78  string Tag3 = HK_Tag3;
79 
80  string DayCom;
81 
82  transform(Value.begin(),Value.end(),Value.begin(), ::tolower);
83  transform(Tag1.begin(),Tag1.end(),Tag1.begin(), ::tolower);
84  transform(Tag2.begin(),Tag2.end(),Tag2.begin(), ::tolower);
85  transform(Tag3.begin(),Tag3.end(),Tag3.begin(), ::tolower);
86  transform(Comments.begin(),Comments.end(),Comments.begin(), ::tolower);
87 
88  if(Tag1.find(Value) != string::npos)
89  Results.Add("Batch " + BatchName + "'s Egg " + to_string(Egg) + ", Tag 1", HK_Tag1);
90 
91  if(Tag2.find(Value) != string::npos)
92  Results.Add("Batch " + BatchName + "'s Egg " + to_string(Egg) + ", Tag 2", HK_Tag2);
93 
94  if(Tag3.find(Value) != string::npos)
95  Results.Add("Batch " + BatchName + "'s Egg " + to_string(Egg) + ", Tag 3", HK_Tag3);
96 
97  if(Comments.find(Value) != string::npos)
98  Results.Add("Batch " + BatchName + "'s Egg " + to_string(Egg) + ", Comments", HK_Comments);
99 
100  for(int A = 0; A < GetDays(); A++) {
101  DayCom = HK_DayComment[A];
102  transform(DayCom.begin(),DayCom.end(),DayCom.begin(), ::tolower);
103 
104  if(DayCom.find(Value) != string::npos)
105  Results.Add("Batch " + BatchName + "'s Egg " + to_string(Egg) + ", Day " + to_string(A + 1) + ", Comments", HK_DayComment[A]);
106  }
107  return Results;
108 }
109 
112  string Tag1,
113  string Tag2,
114  string Tag3,
115  int Fertile,
116  int Pipped,
117  int Result,
118  HK_Date Date,
119  string Comments,
120  vector<HK_Weight> DayWeight,
121  vector<string> DayComments
122 )
123 {
124  HK_Tag1 = Tag1;
125  HK_Tag2 = Tag2;
126  HK_Tag3 = Tag3;
127  HK_Fertile = Fertile;
128  HK_Pipped = Pipped;
129  HK_Result = Result;
130  HK_ResultDate = Date;
131  HK_Comments = Comments;
132  HK_DayWeight = DayWeight;
133  HK_DayComment = DayComments;
134 }
135 
137 void HK_Egg::SetTag1(string Tag){HK_Tag1 = Tag;}
139 void HK_Egg::SetTag2(string Tag){HK_Tag2 = Tag;}
141 void HK_Egg::SetTag3(string Tag){HK_Tag3 = Tag;}
143 void HK_Egg::SetFertile(int Fertile){HK_Fertile = Fertile;}
145 void HK_Egg::SetPipped(int Pipped){HK_Pipped = Pipped;}
147 void HK_Egg::SetResult(int Result){HK_Result = Result;}
151 void HK_Egg::SetComments(string Comments){HK_Comments = Comments;}
153 void HK_Egg::SetDayWeight(vector<HK_Weight> Weight){HK_DayWeight = Weight;}
155 void HK_Egg::AddDayWeight(HK_Weight Weight){HK_DayWeight.push_back(Weight);}
157 void HK_Egg::SetDayComments(vector<string> Comments){HK_DayComment = Comments;}
159 void HK_Egg::AddDayComments(string Comments){HK_DayComment.push_back(Comments);}
A Class For Managing Dates.
Definition: Date.h:25
int GetResult()
Returns -1 If No Result, 0 If Hatched, And 2 If Egg Quit.
Definition: HK_Egg.cpp:58
string GetComments()
Returns Egg Comments.
Definition: HK_Egg.cpp:64
HK_Date HK_ResultDate
Holds Result Date.
Definition: Egg.h:32
int CalcDayLoss(int Day)
Returns The Percentage Of Weight Lost From Previous Weighing.
Definition: HK_Egg.cpp:24
void SetDayWeight(vector< HK_Weight > Weight)
Sets Weight For All Days.
Definition: HK_Egg.cpp:153
int HK_Fertile
0 == Unfertile, 1 == Fertile
Definition: Egg.h:29
void SetDate(HK_Date Date)
Sets Result Date.
Definition: HK_Egg.cpp:149
string HK_Comments
Holds Comments For Egg.
Definition: Egg.h:33
int HK_Result
-1 == No Result, 0 == Quit, 1 == Hatched
Definition: Egg.h:31
void SetComments(string Comments)
Sets Egg Comments.
Definition: HK_Egg.cpp:151
int GetDays()
Returns The Number Of Days For This Egg.
Definition: HK_Egg.cpp:62
string GetTag2()
Returns Tag 2 As A String.
Definition: HK_Egg.cpp:50
void Set(string Tag1, string Tag2, string Tag3, int Fertile, int Pipped, int Result, HK_Date Date, string Comments, vector< HK_Weight > DayWeight, vector< string > DayComments)
Sets All Data In One Function.
Definition: HK_Egg.cpp:111
int CalcTotalLoss()
Returns The Total Percentage Of Weight Lost By This Egg.
Definition: HK_Egg.cpp:38
vector< string > HK_DayComment
Holds 1 Comment per day.
Definition: Egg.h:35
void SetResult(int Result)
Sets Result Status.
Definition: HK_Egg.cpp:147
string HK_Tag3
Holds Tag 3 For Egg.
Definition: Egg.h:28
HK_Date GetDate()
Returns The Date For The Result.
Definition: HK_Egg.cpp:60
string GetTag3()
Returns Tag 3 As A String.
Definition: HK_Egg.cpp:52
vector< HK_Weight > HK_DayWeight
Holds 1 weight per day.
Definition: Egg.h:34
string HK_Tag1
Holds Tag 1 For Egg.
Definition: Egg.h:26
void SetTag3(string Tag)
Sets The Third Tag.
Definition: HK_Egg.cpp:141
void SetTag1(string Tag)
Sets The First Tag.
Definition: HK_Egg.cpp:137
HK_Egg()
Default Constructor.
Definition: HK_Egg.cpp:12
void SetFertile(int Fertile)
Sets Fertile Status.
Definition: HK_Egg.cpp:143
vector< string > GetDayComments()
Returns An Array Containing A Comment For Every Day.
Definition: HK_Egg.cpp:68
string HK_Tag2
Holds Tag 2 For Egg.
Definition: Egg.h:27
void ClearDayData()
Clears And Shrinks The Day Data Arrays.
Definition: HK_Egg.cpp:15
void AddDayWeight(HK_Weight Weight)
Adds Weight For Another Day.
Definition: HK_Egg.cpp:155
void AddDayComments(string Comments)
Adds Comments For Another Day.
Definition: HK_Egg.cpp:159
vector< HK_Weight > GetDayWeight()
Returns An Array Containing A Weight For Every Day.
Definition: HK_Egg.cpp:66
void SetPipped(int Pipped)
Sets Pip Status.
Definition: HK_Egg.cpp:145
void SetTag2(string Tag)
Sets The Second Tag.
Definition: HK_Egg.cpp:139
int GetPipped()
Returns 0 If Egg Is Not Pipped And 1 If It Is.
Definition: HK_Egg.cpp:56
string GetTag1()
Returns Tag 1 As A String.
Definition: HK_Egg.cpp:48
HK_KeyValue Search(string Value, string BatchName, int Egg)
Searches This Egg For Matches To Value.
Definition: HK_Egg.cpp:71
int GetFertile()
Returns 0 If Egg Is Not Fertile And 1 If It Is.
Definition: HK_Egg.cpp:54
void SetDayComments(vector< string > Comments)
Sets Comments For All Days.
Definition: HK_Egg.cpp:157
int HK_Pipped
0 == Unpipped, 1 == Pipped
Definition: Egg.h:30
A Key and Value Type Storage.
Definition: KeyValue.h:25
void Add(string Key, string Value)
Adds A Key And Value;.
Definition: HK_KeyValue.cpp:33
A Class For Managing Data For One Weight.
Definition: Weight.h:24