-
Notifications
You must be signed in to change notification settings - Fork 0
/
PetDatabase.h
96 lines (74 loc) · 1.84 KB
/
PetDatabase.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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: PetDatabase.h
* Author: dj2
*
* Created on February 19, 2018, 11:43 AM
*/
#ifndef PETDATABASE_H
#define PETDATABASE_H
#include <vector>
#include "Pet.h"
using namespace std;
class PetDatabase {
public:
PetDatabase(PetDatabase* db){
pets = vector<Pet*>();
for(uint i = 0; i < db->pets.size(); i++){
insertPet(*db->pets[i]);
}
}
PetDatabase(){
}
PetDatabase(vector<Pet*> petVector){
pets = vector<Pet*>();
for(uint i = 0; i < petVector.size(); i++){
insertPet(*petVector[i]);
}
}
PetDatabase(const PetDatabase& db) {
if (this != &db) {
pets = vector<Pet*>();
for(uint i = 0; i < db.pets.size(); i++){
insertPet(*db.pets[i]);
}
}
}
PetDatabase& operator=(const PetDatabase& db) {
if (this != &db) {
pets = vector<Pet*>();
for(uint i = 0; i < db.pets.size(); i++){
insertPet(*db.pets[i]);
}
}
return *this;
}
virtual ~PetDatabase() {}
int getSize() const {
return pets.size();
}
void swap(int i, int j){
Pet* temp = pets[i];
pets[i] = pets[j];
pets[j] = temp;
}
void DisplayRecords() const {
for(uint i = 0; i < pets.size(); i++){
cout << "printing" << endl;
pets[i]->print();
}
}
Pet* getPet(int i) const {
return pets[i];
}
void insertPet(Pet& pet){
pets.push_back(&pet);
}
private:
vector<Pet*> pets;
};
#endif /* PETDATABASE_H */