-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlowerLibrary.cpp
More file actions
81 lines (69 loc) · 2.19 KB
/
FlowerLibrary.cpp
File metadata and controls
81 lines (69 loc) · 2.19 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
//
// Berk Temel 22002675
//
#include "FlowerLibrary.h"
FlowerLibrary::FlowerLibrary() {
}
FlowerLibrary::~FlowerLibrary() {
}
void FlowerLibrary::addFlower(string name) {
toLowerCase(name);
bool isAdded = flowers.add(name);
if(isAdded) {
cout << name << " has been added into the library." << endl;
} else {
cout << name << " cannot be added into the library because it already exists." << endl;
}
}
void FlowerLibrary::removeFlower(string name) {
toLowerCase(name);
bool isRemoved = flowers.remove(name);
if(isRemoved) {
cout << name << " has been removed from the library." << endl;
} else {
cout << name << " cannot be removed because it's not in the library." << endl;
}
}
void FlowerLibrary::listFlowers() const {
flowers.printList();
}
void FlowerLibrary::listFeatures(string name) const {
toLowerCase(name);
flowers.printAFlower(name);
}
void FlowerLibrary::addFeature(string name, string feature) {
toLowerCase(name);
toLowerCase(feature);
bool added = flowers.addFeature(name, feature);
if(added)
cout << feature << " is added into " << name << endl;
else{
if(!flowers.nameExists(name))
cout << name << " isn't found in the library." << endl;
else
cout << feature << " already exists in " << name << endl;
}
}
void FlowerLibrary::removeFeature(string name, string feature) {
toLowerCase(name);
toLowerCase(feature);
bool removed = flowers.removeFeature(name, feature);
if(removed)
cout << feature << " is removed from " << name << endl;
else {
if(!flowers.nameExists(name))
cout << name << " isn't found in the library." << endl;
else
cout << feature << " doesn't exists in " << name << endl;
}
}
void FlowerLibrary::findFlowers(string feature) const {
toLowerCase(feature);
flowers.findFeatures(feature);
}
void FlowerLibrary::toLowerCase(string &str) const {
for(int i = 0; i < str.size(); i++) {
if(str.at(i) <= 90 && str.at(i) >= 65 )
str.at(i) = str.at(i) + 32;
}
}