-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathanimal.h
More file actions
162 lines (119 loc) · 3.4 KB
/
animal.h
File metadata and controls
162 lines (119 loc) · 3.4 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#pragma once
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
class Animal
{
protected:
int Paws;
Animal(int paws) { Paws = paws; }
public:
virtual string about() const
{
return "";
}
int setPaws(int paws_) { Paws = paws_; }
void getPaws() { cout << Paws; }
};
class Mammal : public Animal
{
protected:
Mammal(int paws, string squad) : Animal(paws) { Squad = squad; }
string Squad;
virtual string about() const
{
stringstream ss;
ss << "Paws: " << Paws << ", " << "Squad: " << Squad << endl;
return ss.str();
}
public:
string setSquad(string squad_) { Squad = squad_; }
void getSquad() { cout << Squad; }
};
class Cat : public Mammal
{
protected:
float Vibrissae_length;
int Lives_number;
public:
Cat(int paws, string squad, float vibrissae_length, int lives_number) : Mammal(paws, squad) { Vibrissae_length = vibrissae_length; Lives_number = lives_number; }
float setVibrissae_length(float vibrissae_length_) { Vibrissae_length = vibrissae_length_; }
void getVibrissae_length() { cout << Vibrissae_length; }
int setLives_number(int lives_number_) { Lives_number = lives_number_; }
void getLives_number() { cout << Lives_number; }
virtual string about() const
{
stringstream ss;
ss << "Paws: " << Paws << ", Squad: " << Squad << ", Vibrissae length: " << Vibrissae_length << ", Lives number: " << Lives_number << endl;
return ss.str();
}
};
class Cow : public Mammal
{
protected:
int Spots_number;
int Milk_volume;
public:
Cow(int paws, string squad, int spots_number, int milk_volume) : Mammal(paws, squad) { Spots_number = spots_number; Milk_volume = milk_volume; }
Cow(int paws, string squad, int spots_number) : Mammal(paws, squad) { Spots_number = spots_number; Milk_volume = 0; }
int setSpots_number(int spots_number_) { Spots_number = spots_number_; }
void getSpots_number() { cout << Spots_number; }
int setMilk_volume(int milk_volume_) { Milk_volume = milk_volume_; }
void getMilk_volume() { cout << Milk_volume; }
virtual string about() const
{
stringstream ss;
ss << "Paws: " << Paws << ", Squad: " << Squad << ", Spots number: " << Spots_number << ", Milk volume: " << Milk_volume << endl;
return ss.str();
}
};
class Reptile : public Animal
{
protected:
bool Shell;
Reptile(int paws, bool shell) : Animal(paws) { Shell = shell; }
virtual string about() const
{
stringstream ss;
ss << "Paws: " << Paws << ", " << "Shell: " << Shell << endl;
return ss.str();
}
public:
bool setShell(bool shell_) { Shell = shell_; }
void getShell() { cout << Shell; }
};
class Snake : public Reptile
{
protected:
float Lenth;
public:
Snake(int paws, bool shell, float lenth) : Reptile(paws, shell) { Lenth = lenth; }
float setLenth(float lenth_) { Lenth = lenth_; }
void getLenth() { cout << Lenth; }
virtual string about() const
{
stringstream ss;
ss << "Paws: " << Paws << ", Shell: " << Shell << ", Lenth: " << Lenth << endl;
return ss.str();
}
};
class Turtle : public Reptile
{
private:
string Area;
public:
Turtle(int paws, bool shell, string area) : Reptile(paws, shell) { Area = area; }
string setArea(string area_) { Area = area_; }
void getArea() { cout << Area; }
virtual string about() const
{
stringstream ss;
ss << "Paws: " << Paws << ", Shell: " << Shell << ", Area: " << Area << endl;
return ss.str();
}
};
inline ostream& operator<< (ostream& os, const Animal& animal)
{
return os << animal.about();
}