aboutsummaryrefslogtreecommitdiff
path: root/oop2w6/ShowVisitor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'oop2w6/ShowVisitor.cpp')
-rw-r--r--oop2w6/ShowVisitor.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/oop2w6/ShowVisitor.cpp b/oop2w6/ShowVisitor.cpp
new file mode 100644
index 0000000..f30b701
--- /dev/null
+++ b/oop2w6/ShowVisitor.cpp
@@ -0,0 +1,24 @@
+#include <iostream>
+
+#include "Resistor.h"
+#include "Capacitor.h"
+#include "Inductor.h"
+#include "ShowVisitor.h"
+
+void ShowVisitor::visit(Resistor& resistor) {
+ std::cout << "resistor" << std::endl;
+ std::cout << " value " << resistor.getValue() << std::endl;
+ std::cout << " tolerance " << resistor.getTolerance() << std::endl;
+}
+
+void ShowVisitor::visit(Capacitor& capacitor) {
+ std::cout << "capacitor" << std::endl;
+ std::cout << " value " << capacitor.getValue() << std::endl;
+ std::cout << " electrolitic " << (capacitor.isElectrolitic() ? "yes" : "no") << std::endl;
+}
+
+void ShowVisitor::visit(Inductor& inductor) {
+ std::cout << "inductor" << std::endl;
+ std::cout << " value " << inductor.getValue() << std::endl;
+ std::cout << " saturable " << ( inductor.isSaturable() ? "yes" : "no" ) << std::endl;
+}