From c15879016be8e2686904b003fb9b9de0ad91cf08 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 24 Apr 2017 23:06:26 -0400 Subject: [PATCH] Fix All the errors --- src/Simulation.cpp | 4 ++-- src/Wire.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Simulation.cpp b/src/Simulation.cpp index ea90ec0..5714ddf 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -183,9 +183,9 @@ void Simulation::print() } int t = 0; - cout << setw(10) << "TIME"; + cout << setw(10) << "TIME "; while(t <= 60 && t <= lastTime) { - cout << setw(5) << t; + cout << setw(5) << left << t; t += 5; } } diff --git a/src/Wire.cpp b/src/Wire.cpp index bb3ccac..8eeb31d 100644 --- a/src/Wire.cpp +++ b/src/Wire.cpp @@ -11,15 +11,18 @@ Wire::Wire(int number, bool io, string inName) int Wire::getValue(int wantedTime) const { + int tmp; if (historyTimes.size() == 0 || wantedTime < historyTimes[0]) { return -1; } else { for (auto i = historyTimes.begin(); i != historyTimes.end(); i++) { if (*i > wantedTime) { - return historyValues[i - 1 - historyTimes.begin()]; + tmp = i - historyTimes.begin(); + return historyValues[tmp - 1]; } } + return *(historyValues.end()-1); } } @@ -92,7 +95,7 @@ ostream & operator<<(ostream & out, const Wire & c) { if (c.isPrint) { int len = 0; - out << setw(10) << c.name; + out << setw(10) << c.name + " "; while (len <= 60 && len <= c.lastEvent) { out << setw(0) << c.getChar(len++);