-
Notifications
You must be signed in to change notification settings - Fork 0
/
Review.cpp
64 lines (55 loc) · 1.47 KB
/
Review.cpp
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
//
// Created by hloi on 10/14/2021.
//
#include <sstream>
#include <fstream>
#include <iostream>
#include "Review.h"
using namespace std;
Review::Review() {
isModified = false;
}
Review::Review(string filename) {
this->filename = filename;
}
void Review::ReadReview() {
ifstream inFS; // Input file stream
string userName;
int userRating;
Review currentReview;
// Open file
inFS.open(filename);
if (!inFS.is_open()) {
cout << "Could not open file Trattoria_Reviews.txt."<< endl;
}
getline(inFS, restaurantName);
while (!inFS.eof()) {
string line;
getline(inFS, line);
if (!inFS.fail()) {
string token;
std::istringstream ss(line);
getline(ss, token, ',');
string userName = token;
getline(ss, token, ',');
int rating = stoi(token);
Reviewer rv(userName, rating);
reviewList.push_back(rv);
}
}
// Close file when done reading
inFS.close();
}
//void Review::ReviewersReport(string& reportName) {
// int i;
//
// cout << endl << restaurantName << endl;
// cout << "Average rating: " << ratingAvg << endl;
// cout << "--------------------" << endl;
//
// for(i = 0; i < reviewList.size(); ++i) {
// cout << "User name: " << reviewList.at(i).GetUserName() << endl;
// cout << " Rating: " << reviewList.at(i).GetRating() << endl;
// cout << endl;
// }
//}