HatchKeeper  0.90
The Free Open-Source Egg Incubation Software
HK_Weight.cpp
Go to the documentation of this file.
1 /*******************************************************************/
9 #include "../headers/Weight.h"
10 
13 
16 {
17  if(IsZero() || Weight.IsZero())
18  return 0;
19 
20  float Subtract = HK_WeightFloat - Weight.GetFloat();
21  float Percent = Subtract / HK_WeightFloat;
22  int Percent2 = Percent * 100;
23  return Percent2;
24 }
25 
28 {
29  if(HK_WeightFloat < 0.0001)
30  return true;
31  return false;
32 }
33 
40 
42 string HK_Weight::Round(float Number)
43 {
44  string F = to_string(Number);
45  unsigned int Period = F.find(".");
46  if(Period != string::npos)
47  return F.erase((Period + 4),F.length());
48  return F;
49 }
50 
52 void HK_Weight::Set(float Weight){HK_WeightFloat = Weight;}
54 void HK_Weight::Set(double Weight){HK_WeightFloat = Weight;}
56 void HK_Weight::Set(int Weight){HK_WeightFloat = Weight;}
58 void HK_Weight::Set(string Weight){HK_WeightFloat = stof(Weight);}
A Class For Managing Data For One Weight.
Definition: Weight.h:24
HK_Weight()
Constructor.
Definition: HK_Weight.cpp:12
void Set(float Weight)
Sets The Weight Value Using A Float.
Definition: HK_Weight.cpp:52
int DiffPercent(HK_Weight Weight)
Returns The Percentage Difference Between This And Input Weight.
Definition: HK_Weight.cpp:15
string Round(float Number)
Rounds Float To 3 Decimal Places.
Definition: HK_Weight.cpp:42
float GetFloat()
Returns Weight As Float.
Definition: HK_Weight.cpp:35
float HK_WeightFloat
Definition: Weight.h:26
int GetInt()
Returns Weight As Int.
Definition: HK_Weight.cpp:37
string GetString()
Returns Weight As String.
Definition: HK_Weight.cpp:39
bool IsZero()
Returns True If Weight Is Zero.
Definition: HK_Weight.cpp:27