Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Food/Food.cpp@15:130900e5c268, 2018-05-08 (annotated)
- Committer:
- Andrew_M
- Date:
- Tue May 08 14:06:47 2018 +0000
- Revision:
- 15:130900e5c268
- Parent:
- 7:c1e0593bfc99
- Child:
- 17:2a909f7da973
Added a large amount of explanatory comments
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Andrew_M | 5:a3a9e0417e04 | 1 | #include "Food.h" |
Andrew_M | 5:a3a9e0417e04 | 2 | |
Andrew_M | 5:a3a9e0417e04 | 3 | // nothing doing in the constructor and destructor |
Andrew_M | 5:a3a9e0417e04 | 4 | Food::Food() |
Andrew_M | 5:a3a9e0417e04 | 5 | { |
Andrew_M | 5:a3a9e0417e04 | 6 | |
Andrew_M | 5:a3a9e0417e04 | 7 | } |
Andrew_M | 5:a3a9e0417e04 | 8 | |
Andrew_M | 5:a3a9e0417e04 | 9 | Food::~Food() |
Andrew_M | 5:a3a9e0417e04 | 10 | { |
Andrew_M | 5:a3a9e0417e04 | 11 | |
Andrew_M | 5:a3a9e0417e04 | 12 | } |
Andrew_M | 5:a3a9e0417e04 | 13 | |
Andrew_M | 15:130900e5c268 | 14 | //No major comments are needed as all fucntions are simple and self explanatory |
Andrew_M | 15:130900e5c268 | 15 | |
Andrew_M | 5:a3a9e0417e04 | 16 | void Food::init(int x, int y) |
Andrew_M | 15:130900e5c268 | 17 | { |
Andrew_M | 5:a3a9e0417e04 | 18 | _x = x; |
Andrew_M | 5:a3a9e0417e04 | 19 | _y = y; |
Andrew_M | 5:a3a9e0417e04 | 20 | } |
Andrew_M | 5:a3a9e0417e04 | 21 | |
Andrew_M | 5:a3a9e0417e04 | 22 | int Food::getX() |
Andrew_M | 5:a3a9e0417e04 | 23 | { |
Andrew_M | 5:a3a9e0417e04 | 24 | return _x; |
Andrew_M | 5:a3a9e0417e04 | 25 | } |
Andrew_M | 5:a3a9e0417e04 | 26 | |
Andrew_M | 5:a3a9e0417e04 | 27 | int Food::getY() |
Andrew_M | 5:a3a9e0417e04 | 28 | { |
Andrew_M | 5:a3a9e0417e04 | 29 | return _y; |
Andrew_M | 7:c1e0593bfc99 | 30 | } |
Andrew_M | 7:c1e0593bfc99 | 31 | |
Andrew_M | 7:c1e0593bfc99 | 32 | void Food::random() |
Andrew_M | 7:c1e0593bfc99 | 33 | { |
Andrew_M | 15:130900e5c268 | 34 | _x = rand() % 22; //randomly generates a number between 0 and 21 |
Andrew_M | 7:c1e0593bfc99 | 35 | _y = rand() % 22; |
Andrew_M | 5:a3a9e0417e04 | 36 | } |