-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibrary.cpp
More file actions
43 lines (38 loc) · 858 Bytes
/
Library.cpp
File metadata and controls
43 lines (38 loc) · 858 Bytes
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
//include headers and libraries
#include <iostream>
#include <array>
#include <string>
#include "Library.h"
using namespace std;
//implement class functions
Library::Library(){
string books[10];
}
bool Library::addBook(string bookName) {
for(int i=0; i<10; i++){
if(books[i] == ""){
books[i] = bookName;
return true;
}
}
cout << "Cannot add the book.";
return false;
}
bool Library::removeBook(string bookName) {
for (int i = 0; i <= 10; i++) {
if (books[i] == bookName) {
books[i] = "";
return true;
}
}
cout << "Cannot remove the book.";
return false;
}
void Library::print() {
cout << "Library contents: \n";
for (int i = 0; i < 10; i++) {
if (books[i] != "") {
cout << books[i] << endl;
}
}
}