add print function

This commit is contained in:
Joel Beckmeyer 2017-04-24 21:09:38 -04:00
parent 081330103c
commit 6f256eb395
1 changed files with 21 additions and 1 deletions

View File

@ -1,4 +1,6 @@
#include "Simulation.h"
#include <iostream>
#include <iomanip>
bool Simulation::parseCircuit(string fileName)
{
@ -135,10 +137,28 @@ void Simulation::simulate() {
void Simulation::print()
{
// iterate through wires, printing each of them
int lastTime = 0;
int tmpTime = 0;
// iterate through wires, finding wire with last event time
for(auto i = wires.begin(); i != wires.end(); ++i) {
if(i->getLast() > lastTime) {
lastTime = i->getLast();
}
}
// now iterate through wires, printing each of them
for(auto i = wires.begin(); i != wires.end(); ++i) {
i->setLast(lastTime);
cout << *i;
}
int t = 0;
cout << setw(10) << "TIME";
cout.setw(5);
while(t <= 60 && t <= lastTime) {
cout << t;
t += 5;
}
}
Wire * Simulation::findWire(int n)