ZIYI CHEN ml17z4c 201214999
Dependencies: mbed
Food/Food.cpp@7:8b6f175fcb0e, 2019-04-30 (annotated)
- Committer:
- ziyi11
- Date:
- Tue Apr 30 09:14:17 2019 +0000
- Revision:
- 7:8b6f175fcb0e
- Child:
- 8:52e0506e98b8
add food and menu;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ziyi11 | 7:8b6f175fcb0e | 1 | #include "Food.h" |
ziyi11 | 7:8b6f175fcb0e | 2 | |
ziyi11 | 7:8b6f175fcb0e | 3 | // nothing doing in the constructor and destructor |
ziyi11 | 7:8b6f175fcb0e | 4 | Food::Food() |
ziyi11 | 7:8b6f175fcb0e | 5 | { |
ziyi11 | 7:8b6f175fcb0e | 6 | |
ziyi11 | 7:8b6f175fcb0e | 7 | } |
ziyi11 | 7:8b6f175fcb0e | 8 | |
ziyi11 | 7:8b6f175fcb0e | 9 | Food::~Food() |
ziyi11 | 7:8b6f175fcb0e | 10 | { |
ziyi11 | 7:8b6f175fcb0e | 11 | |
ziyi11 | 7:8b6f175fcb0e | 12 | } |
ziyi11 | 7:8b6f175fcb0e | 13 | |
ziyi11 | 7:8b6f175fcb0e | 14 | //No major comments are needed as all fucntions are simple and self explanatory |
ziyi11 | 7:8b6f175fcb0e | 15 | |
ziyi11 | 7:8b6f175fcb0e | 16 | void Food::init(int x, int y) |
ziyi11 | 7:8b6f175fcb0e | 17 | { |
ziyi11 | 7:8b6f175fcb0e | 18 | _x = x; |
ziyi11 | 7:8b6f175fcb0e | 19 | _y = y; |
ziyi11 | 7:8b6f175fcb0e | 20 | |
ziyi11 | 7:8b6f175fcb0e | 21 | printf("Food initialised\n"); |
ziyi11 | 7:8b6f175fcb0e | 22 | } |
ziyi11 | 7:8b6f175fcb0e | 23 | |
ziyi11 | 7:8b6f175fcb0e | 24 | int Food::getX() |
ziyi11 | 7:8b6f175fcb0e | 25 | { |
ziyi11 | 7:8b6f175fcb0e | 26 | return _x; |
ziyi11 | 7:8b6f175fcb0e | 27 | } |
ziyi11 | 7:8b6f175fcb0e | 28 | |
ziyi11 | 7:8b6f175fcb0e | 29 | int Food::getY() |
ziyi11 | 7:8b6f175fcb0e | 30 | { |
ziyi11 | 7:8b6f175fcb0e | 31 | return _y; |
ziyi11 | 7:8b6f175fcb0e | 32 | } |
ziyi11 | 7:8b6f175fcb0e | 33 | |
ziyi11 | 7:8b6f175fcb0e | 34 | void Food::random() |
ziyi11 | 7:8b6f175fcb0e | 35 | { |
ziyi11 | 7:8b6f175fcb0e | 36 | _x = rand() % 48; //randomly generates a number between 0 and 21 |
ziyi11 | 7:8b6f175fcb0e | 37 | _y = rand() % 84; |
ziyi11 | 7:8b6f175fcb0e | 38 | } |