-
Notifications
You must be signed in to change notification settings - Fork 0
/
Zoo.h
99 lines (64 loc) · 2.03 KB
/
Zoo.h
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
// File: Zoo.h
//
// A Zoo has an owner and animals in the order they were caught.
//
// A new Zoo has no animals and owner is the string you give it.
#ifndef ZOO_H
#define ZOO_H
#include <iostream>
#include <string>
using namespace std;
class Zoo {
private:
string owner; // owner's name
string *cage; // dynamic array of animals, 1 string/animal
int count; // # of animals in Zoo, size of cage
public:
// Constructor 1
Zoo();
// Pre: none
// Post: owner's name has been initialized to "nobody".
// count is set to 0.
// cage pointer is set to NULL.
// Constructor 2
Zoo(string n);
// Pre: none
// Post: owner's name has been initialized to n.
// count is set to 0.
// cage pointer is set to NULL.
// destructor
~Zoo();
// MEMBER FUNCTIONS
string name();
// Pre: none
// Post: returns owner's name
void operator=(const Zoo& z); // assignment operator
// Pre: none
// Modifies: self
// Post: Copy's all animals to self. Does not change owner.
// FRIEND FUNCTIONS
friend Zoo operator+(const Zoo& z, string a);
// Pre: none
// Post: returns z with same owner and animals,
// animal a added to the end.
friend ostream& operator<<(ostream& out, const Zoo& z);
// Pre: none
// Post: prints out z's contents (animal1, animal2, etc.),
// and returns out stream.
friend bool operator<=(string a, const Zoo& z);
// Pre: none
// Post: returns true if animal a is in Zoo z.
// the owner does not count as an animal.
}; // end class Zoo
// NONMEMBER FUNCTIONS
Zoo operator+(string a, const Zoo&);
// Pre: none
// Post: returns z with same owner and animals,
// animal a added to the end.
void operator+=(Zoo& z, string a);
// Pre: none
// Modifies: z
// Post: z has same animals and owner,
// animal a added to the end.
// returns the modified z.
#endif