Advertisement
Glocke

Engine.cpp

Jan 7th, 2013
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include "Engine.hpp"
  3.  
  4. Engine::Engine(const std::string name, int limit) {
  5.     this->user = new User(name);
  6.     this->limit = limit;
  7. }
  8.  
  9. Engine::~Engine() {
  10.     delete this->user;
  11. }
  12.  
  13. void Engine::run() {
  14.     while (!(this->user->finished(this->limit))) {
  15.         this->user->inc();
  16.     }
  17. }
  18.  
  19. User::User(const std::string name) {
  20.     this->name = name;
  21.     this->counter = 0;
  22. }
  23.  
  24. void User::inc() {
  25.     this->counter += 1;
  26.     std::cout << "New value is of '" << this->name << "' is " << this->counter << std::endl;
  27. }
  28.  
  29. bool User::finished(int limit) {
  30.     return (this->counter >= limit);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement