Commit 3a8291e5 authored by Alexis Lebis's avatar Alexis Lebis

fix m3tal/csdvp-evolutionary-alogirthm-optimization#3

Mostly due to a bad vector access in the overriden operator<<
parent a9494406
...@@ -18,7 +18,7 @@ int Course::COURSE_COUNTER = 0; ...@@ -18,7 +18,7 @@ int Course::COURSE_COUNTER = 0;
Course Course::build(int ects, std::string name) Course Course::build(int ects, std::string name)
{ {
int id = Course::assignID(); int id = Course::assignID();
if(name.empty()) if(name.empty())
name = "Course#"+std::to_string(id); name = "Course#"+std::to_string(id);
...@@ -234,10 +234,13 @@ std::ostream& operator<<(std::ostream& Stream, const Course & c) ...@@ -234,10 +234,13 @@ std::ostream& operator<<(std::ostream& Stream, const Course & c)
{ {
std::string s = "Course\n\tid:"+std::to_string(c.id())+"\n\tname:"+c.name()+"\n\tECTS: "+std::to_string(c.ects()); std::string s = "Course\n\tid:"+std::to_string(c.id())+"\n\tname:"+c.name()+"\n\tECTS: "+std::to_string(c.ects());
std::string tf; std::string tf;
for(int i = 0; i < c.timeFrame().size()-1; i++) if(c.timeFrame().size() > 0)
tf+=std::to_string(c.timeFrame().at(i))+" ; "; {
tf+=std::to_string(c.timeFrame().at(c.timeFrame().size()-1)); for(int i = 0; i < c.timeFrame().size()-1; i++)
s+="\n\tTimeFrames: ["+tf+"]"; tf+=std::to_string(c.timeFrame().at(i))+" ; ";
tf+=std::to_string(c.timeFrame().at(c.timeFrame().size()-1));
s+="\n\tTimeFrames: ["+tf+"]";
}
Stream << s; Stream << s;
return Stream; return Stream;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment