-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask4.cpp
More file actions
59 lines (47 loc) · 1.2 KB
/
Copy pathtask4.cpp
File metadata and controls
59 lines (47 loc) · 1.2 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
#include <iostream>
using namespace std;
class Book {
private:
string isbn;
int copiesAvailable;
public:
string title;
string author;
Book(string t, string a, string i, int copies) {
title = t;
author = a;
isbn = i;
copiesAvailable = copies;
}
void issueBook() {
if (copiesAvailable > 0) {
copiesAvailable--;
cout << "Book issued successfully." << endl;
} else {
cout << "No copies available to issue." << endl;
}
}
void addCopies(int n) {
if (n > 0) {
copiesAvailable += n;
}
}
void displayDetails() {
cout << "Title: " << title << endl;
cout << "Author: " << author << endl;
cout << "ISBN: " << isbn << endl;
cout << "Copies Available: " << copiesAvailable << endl;
}
};
int main() {
Book b1("The Alchemist", "Paulo Coelho", "9780061122415", 3);
b1.displayDetails();
b1.issueBook();
b1.issueBook();
b1.issueBook();
b1.issueBook();
b1.addCopies(2);
cout << "\nAfter Updates:\n";
b1.displayDetails();
return 0;
}