chore: Add course material
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#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";
|
||||
}
|
||||
Reference in New Issue
Block a user