-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReview.cpp
More file actions
53 lines (44 loc) · 1.08 KB
/
Review.cpp
File metadata and controls
53 lines (44 loc) · 1.08 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
//
// Created by 赵健 on 2021/8/17.
//
#ifndef ANDROIDHELPER_REVIEW_H
#define ANDROIDHELPER_REVIEW_H
#include "Review.h"
#include <iostream>
struct Review {
std::string title;
int rating;
};
bool FillReview(Review &rr) {
std::cout << "Enter book title (quit to quit):";
std::getline(std::cin, rr.title);
if (rr.title == "quit")
return false;
std::cout << "Enter book rating:";
std::cin >> rr.rating;
if (!std::cin)
return false;
// get rid of rest of input line
while (std::cin.get() != '\n') continue;
return true;
}
void ShowReview(const Review &rr) {
std::cout << rr.rating << "\t" << rr.title << std::endl;
}
bool operator<(const Review &r1, const Review &r2) {
if (r1.title < r2.title) {
return true;
} else if (r1.title == r2.title && r1.rating < r2.rating) {
return true;
} else {
return false;
}
}
bool worseThan(const Review &r1, const Review &r2) {
if (r1.rating < r2.rating) {
return true;
} else {
return false;
}
}
#endif //ANDROIDHELPER_REVIEW_H