klips/cpp/patterns/factory/main.cpp

25 lines
699 B
C++
Raw Normal View History

2021-05-11 19:04:58 +00:00
#include <array>
#include <cstdlib>
#include <iostream>
#include <vector>
#include "abstract-factory.hpp"
2021-05-11 19:04:58 +00:00
int main(const int argc, const char * argv[]) {
// Testing GearFactory
GearFactory gearFactory;
const int gearsRequired = 5;
std::cout << "Testing " << gearFactory.getName() <<"...\nMaking 5 Gears...\n";
for (int i = 0; i < gearsRequired; i++) gearFactory.requestPart();
std::cout << std::endl << gearFactory.getName() << " inventory:\n";
gearFactory.showStock();
// Making custom gears
for (int i = 0; i < gearsRequired; i++) gearFactory.requestPart("Big Gear", 2.5f);
std::cout << std::endl << gearFactory.getName() << " inventory:\n";
gearFactory.showStock();
}