-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbook.cpp
More file actions
150 lines (87 loc) · 2.05 KB
/
book.cpp
File metadata and controls
150 lines (87 loc) · 2.05 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
//header files necessary for implementation
#include<iostream>
#include<string>
using namespace std;
//intialisation of other classes for making them friend
class client;
class library;
class book {
//friends
friend class client;
friend class library;
//private data members
string name;
string publication;
int copies;
//private methords
//private accessors
void get_data();
string get_name();
string get_publication();
int get_copies();
//priavte mutators
void set_copies(int);
void set_name(string&);
void set_publication(string&);
//overloaded equality operator for compariisons
bool operator==(book&);
//overloaded extraction operator
friend ostream& operator<<(ostream&,book&);
public:
//public metords
//constructors
book();
book(int);
};
string book::get_publication(){
return this->publication;
}
string book::get_name(){
return this->name;
}
void book::set_publication(string& publication){
//priavte mutator
this->publication=publication;
return ;
}
void book::set_name(string& name){
this->name=name;
return ;
}
book::book(int k){
}
int book::get_copies(){
//priavte methord to return no of copies
return this->copies;
}
bool book::operator==(book& b){
//private methord to compre equality of books
return (b.name==name)&(b.publication==publication);
}
void book::set_copies(int n){
//private methord to set copies
//only to be used by libaray and client
copies=n;
return ;
}
ostream& operator<<(ostream& out,book& b){
//private methord to print the book
out<<"========BOOK========\n";
out<<"NAME :: "<<b.name<<endl;
out<<"PUBLICATION :: "<<b.publication<<endl;
out<<"COPIES :: "<<b.copies<<endl;
return out;
}
void book::get_data(){
//private methord called by the constructor for getting the data
cout<<"enter the name of the book\n";
cin>>name;
cout<<"enter the publication\n";
cin>>publication;
cout<<"enter the no of copies\n";
cin>>copies;
}
book::book(){
//private methord for constuructor just to gaet the essential data;
this->get_data();
}