Website Summary Files Commits Branches @commit @diff @stats
path: root / Utils / Kindle / Book.h
blob: 3a7f34753fd7047d0b26779511c5fb5e502ff6a5 (plain) (blame)
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
#pragma once
#include"vector.hpp"
#include"Page.h"
#include"Pair.hpp"
#include"serialize.h"

class Book {
private:
	string author;
	string title;
	Vector<Pair<string, unsigned>> ratings;		// User name + rate
	Vector<Page> data;							// Pages
	Vector<Pair<string, string>> comments;		// commenter's name + comment

	void addRating(unsigned short r, const string& name);

	void write(unsigned pagesCount);
	void displayBook() const;

	void showComments() const;
	void showRates() const;
	void print() const;
	void displayHelpMenu() const;
public:
	Book() {}
	Book(const string& author, const string& title);

	void writeToFile(std::ofstream& outFile) const;
	void readFromFile(std::ifstream& inFile);
	double getAvarageRating() const;

	friend class Kindle;
};