ELEC2645 (2018/19) / Mbed 2 deprecated ml17z4c_attempt2

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Food Class Reference

Food Class Reference

The Food class. More...

#include <Food.h>

Public Member Functions

 Food ()
 Constructor.
 ~Food ()
 Destructor.
void init (int x, int y)
 Init function.
int xcoordinate ()
 Gets x coordinate of the food.
int ycoordinate ()
 Gets y coordinate of the food.
void random ()
 Generate the location of the food randomly.

Data Fields

int _x
 the integer variables _x and _y

Detailed Description

The Food class.

generate a position of food randomly

Author:
ZIYI CHEN
Date:
May 2019

Definition at line 11 of file Food.h.


Constructor & Destructor Documentation

Food (  )

Constructor.

Definition at line 4 of file Food.cpp.

~Food (  )

Destructor.

Definition at line 9 of file Food.cpp.


Member Function Documentation

void init ( int  x,
int  y 
)

Init function.

Parameters:
setthe position of the food (x,y)

Definition at line 16 of file Food.cpp.

void random (  )

Generate the location of the food randomly.

Definition at line 33 of file Food.cpp.

int xcoordinate (  )

Gets x coordinate of the food.

Returns:
X coordinate

Definition at line 23 of file Food.cpp.

int ycoordinate (  )

Gets y coordinate of the food.

Returns:
Y coordinate

Definition at line 28 of file Food.cpp.


Field Documentation

int _x

the integer variables _x and _y

Definition at line 39 of file Food.h.