-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStims.cpp
84 lines (72 loc) · 1.95 KB
/
Stims.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// Stims.cpp
// FinalProject
//
// Created by Mithilan Sivanesan on 2016-11-15.
// Copyright © 2016 Mithilan Sivanesan. All rights reserved.
//
#include "Stims.hpp"
namespace termproject{
Stims::Stims(std::string n, location l, unsigned i,unsigned f, unsigned d){
stimName = n;
setLocation(l);
setIntensity(i);
frequency = f;
duration = d;
}
Stims::Stims(std::ifstream& fin){
std::string loc;
std::getline(fin,stimName,',');
std::getline(fin,loc,',');
Location = strLocEnum(loc);
fin>>intensity;
fin.ignore(2000,',');
fin>>frequency ;
fin.ignore(2000,',');
fin>>duration;
fin.ignore(2000,'\n');
}
void Stims::setLocation(location ltype){
if(ltype >= abs && ltype <= traps)
Location = ltype;
else{
throw "invalid location";
}
}
void Stims::setIntensity(const unsigned i){
if(i<= 100){
intensity = i;
}
else{
throw "intensity must be between 0 and 100";
}
}
std::ostream& Stims::display(std::ostream& os)const{
os<<stimName<<std::endl
<<" Type = stim"<<std::endl
<<" Location = "<<Location<<std::endl
<<" Intensity = "<<intensity<<std::endl
<<" Frequency = "<<frequency<<std::endl
<<" Duration = "<<duration<<std::endl;
return os;
}
location Stims::strLocEnum(std::string loc){
location conversion;
if(loc == "abs"){
conversion = abs;
}
else if(loc == "front"){
conversion = front;
}
else if(loc == "back"){
conversion = back;
}
else if(loc == "traps"){
conversion = traps;
}
else{
throw "Corrupt File: Invalid Enum";
}
return conversion;
}
}