-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBookCharacter.cpp
More file actions
70 lines (65 loc) · 1.5 KB
/
Copy pathBookCharacter.cpp
File metadata and controls
70 lines (65 loc) · 1.5 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
//
// BookCharacter.cpp
// Project3
//
// Created by Rumeysa Bulut on 29.11.2017.
// Copyright © 2017 Rumeysa Bulut. All rights reserved.
//
#include <vector>
#include <iostream>
#include <sstream>
#include <cmath>
#include "BookCharacter.hpp"
BookCharacter::BookCharacter(){
}
BookCharacter::BookCharacter(string line){
vector<string> Character;
stringstream full_line(line);
string info;
while (getline(full_line, info, '\t')) {
Character.push_back(info);
}
setPageNo(Character[0]);
setLineNo(Character[1]);
setIndex(Character[2]);
if(Character.size() > 3){
setCharacter(Character[3]);
}
generate_key();
}
void BookCharacter::setPageNo(string page_no){
this->pageNo = stoi(page_no);
}
void BookCharacter::setLineNo(string line_no){
this->lineNo = stoi(line_no);
}
void BookCharacter::setIndex(string index){
this->index = stoi(index);
}
void BookCharacter::setCharacter(string character){
this->character = character.c_str()[0];
}
int BookCharacter::getPageNo(){
return pageNo;
}
int BookCharacter::getLineNo(){
return lineNo;
}
int BookCharacter::getIndex(){
return index;
}
char BookCharacter::getCharacter(){
return character;
}
void BookCharacter::generate_key(){
unsigned long key;
int page, line, index;
page = getPageNo();
line = getLineNo();
index = getIndex();
key = page*pow(10,4) + line*pow(10,2) + index;
this->key = key;
}
unsigned long BookCharacter::getKey(){
return key;
}