-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimal.h
More file actions
76 lines (61 loc) · 1.68 KB
/
Copy pathAnimal.h
File metadata and controls
76 lines (61 loc) · 1.68 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Animal.h
*
* Created on: Apr 11, 2020
* Author: 1305052_snhu
*/
#ifndef ANIMAL_H_
#define ANIMAL_H_
#include <iostream>
#include <string>
#include <cctype> // Used for trim function
#include <algorithm> // Used for trim function
#include <locale> // Used for trim function
using namespace std;
class Animal {
public:
Animal();
Animal(char name, int trackNum);
virtual ~Animal();
// Get functions
string GetName();
string GetTrackNum();
string GetType();
string GetSubType();
int GetNumEggs();
int GetIsNursing();
// Set functions
void SetName(string nameToSet);
void SetTrackNum(string numToSet);
void SetType(string typeToSet);
void SetSubType(string subTypeToSet);
void SetNumEggs(int numToSet);
void SetIsNursing(int nursingValue);
virtual void PrintAnimal() = 0; //Makes this an abstract class
protected:
string m_name;
string m_trackNum;
string m_type;
string m_subType;
int m_isNursing;
int m_numEggs;
};
/******************************** Extra General Functions: *********************************/
//Trim whitespace on left side
static inline void ltrim(string &s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) {
return !std::isspace(ch);
}));
}
//Trim whitespace on right side
static inline void rtrim(string &s) {
s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) {
return !std::isspace(ch);
}).base(), s.end());
}
//Trim whitespace on right and left sides
static inline void trim(string &s) {
ltrim(s);
rtrim(s);
}
#endif /* ANIMAL_H_ */