Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "Engine.hpp"
- Engine::Engine(const std::string name, int limit) {
- this->user = new User(name);
- this->limit = limit;
- }
- Engine::~Engine() {
- delete this->user;
- }
- void Engine::run() {
- while (!(this->user->finished(this->limit))) {
- this->user->inc();
- }
- }
- User::User(const std::string name) {
- this->name = name;
- this->counter = 0;
- }
- void User::inc() {
- this->counter += 1;
- std::cout << "New value is of '" << this->name << "' is " << this->counter << std::endl;
- }
- bool User::finished(int limit) {
- return (this->counter >= limit);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement