-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.cpp
More file actions
98 lines (90 loc) · 2.18 KB
/
Copy pathdata.cpp
File metadata and controls
98 lines (90 loc) · 2.18 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
89
90
91
92
93
94
95
96
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
using namespace std;
/*Defining class Person with members and
* member functions
*/
class Person{
public:
vector<string> emotions;
vector<double> emotionval;
Person(vector<string> data):emotions(data){}
~Person(){}
void getValues();
void display();
void displayMax();
void temp();
};
/* defining function getValues
* getValues populates the vector of doubles that
* is a member of Person
*/
void Person::getValues(){
for(auto in = emotions.begin(); in != emotions.end(); ++in){
in++;
emotionval.push_back(stod(*in));
}
}
/* defining fuction display
* display lists the emotion along with its value
*/
void Person::display(){
for(auto in = emotions.begin(); in != emotions.end(); ++in){
cout<<*in<<endl;
}
}
/*defining fuction temp
* displays only the double values of each emotion in order
*/
void Person::temp(){
for(auto in = emotionval.begin(); in != emotionval.end(); ++in){
cout<<*in<<endl;
}
}
/* defining function displayMax
* displays the emotion with the highest value
*/
void Person::displayMax(){
double compare = emotionval[0];
int index = 0;
for(auto in = emotionval.begin(); in != emotionval.end(); ++in){
if(compare < (*in)){
compare = *in;
index++;
}
}
cout<<"Highest emotion: "<< emotions[(index*2)]<<compare<<endl;
}
int main(){
cout<<"C++ File executing"<<endl;
vector<Person *> people;
string stuff;
string words;
vector<string> hold;
//opens the textfile Test to read data gathered from the jpgs
ifstream input ("Test");
if(input.is_open()){
while(getline(input,stuff)){
stringstream read(stuff);
//pushes strings into the vector of strings
while(read >> words)
hold.push_back(words);
Person *insert = new Person(hold);//creates a new person for each input
hold.clear();
people.push_back(insert);
}
input.close();
}
else
cout<<"Can't open file"<<endl;
//Displays data by iteration through each Person object
for(auto in = people.begin(); in != people.end(); ++in){
(*in)->getValues();
(*in)->temp();
(*in)->displayMax();
}
return 0;
}