aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk6/lab5/Bug.hpp
blob: f3bfae15df0e6e882ecc2fed52874bb6514dfac5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>

#ifndef BUG_H

#define BUG_H
class Bug {
private:
  int position, dir;
public:
  Bug() {
    position=0;
    dir=1;
  }
  Bug(int pos) {
    position=pos;
    dir=1;
  }
  void move() {
    position+=dir;
  }
  void turn() {
    dir*=-1;
  }
  void display() {
    std::cout << "position = " << position << ", direction = " << dir << std::endl;
  }
};
#endif