23 lines
462 B
C++
23 lines
462 B
C++
#include "PowerVisitor.h"
|
|
#include "Light.h"
|
|
#include "Pole.h"
|
|
#include <iostream>
|
|
|
|
void PowerVisitor::visit(Light &l) {
|
|
switch (l.get()) {
|
|
case Light::ON:
|
|
runningTotal += 60;
|
|
break;
|
|
case Light::FLASH:
|
|
runningTotal += 30;
|
|
break;
|
|
}
|
|
}
|
|
|
|
void PowerVisitor::calculatePower(Pole &p) {
|
|
runningTotal = 0;
|
|
|
|
p.accept(*this);
|
|
|
|
std::cout << "Power usage is " << runningTotal << " watts.\n";
|
|
} |