-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBook.cpp
More file actions
88 lines (79 loc) · 1.99 KB
/
Copy pathBook.cpp
File metadata and controls
88 lines (79 loc) · 1.99 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
#include "Book.h"
#include <string.h>
#include <stdexcept>
#include <limits>
char* Book::getTitle() {
return bookTitle;
}
void Book::setTitle(char* title){
strcpy(bookTitle,title);
}
char* Book::getAuthor() {
return bookAuthor;
}
void Book::setAuthor(char* author){
strcpy(bookAuthor,author);
}
char* Book::getPublisher() {
return bookPublisher;
}
void Book::setPublisher(char* publisher){
strcpy(bookPublisher,publisher);
}
char* Book::getCategory() {
return bookCategory;
}
void Book::setCategory(char* category){
strcpy(bookCategory,category);
}
double Book::getPrice() {
return bookPrice;
}
void Book::setPrice(double price){
bookPrice=price;
}
void Book::displayBookDetails(){
cout<<"\nthe title is :"<<getTitle()<<endl;
cout<<"the Author is :"<<getAuthor()<<endl;
cout<<"the publisher is :"<<getPublisher()<<endl;
cout<<"the category is :"<<getCategory()<<endl;
cout<<"the price is :"<<getPrice()<<endl;
}
void Book::ctreateBook(){
cout<<"\nPlease enter title : ";
cin.ignore();
cin.getline(bookTitle,40);
setTitle(bookTitle);
cout<<"\nPlease enter author : ";
cin.getline(bookAuthor,40);
setAuthor(bookAuthor);
cout<<"\nPlease enter publisher : ";
cin.getline(bookPublisher,40);
setPublisher(bookPublisher);
cout<<"\nPlease enter category : ";
cin.getline(bookCategory,40);
setCategory(bookCategory);
cout<<"\nPlease enter price : ";
cin>>bookPrice;
while(cin.fail())
{
cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(),'\n');
cout << "Bad entry.Price Must be Number, PLEASE Enter a NUMBER : ";
cin >> bookPrice;
}
setPrice(bookPrice);
}
//compare By price
bool Book::operator==( const Book check) const{
if(bookPrice != check.bookPrice)
return false;
else
return true;
}
bool Book::operator<( const Book check) const{
if(bookPrice < check.bookPrice)
return true;
else
return false;
}