aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk6/lab5/Bug.hpp
blob: cc704ab133451df20a4f5d5360d70a8a1ea4347e (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