2036 mbed lab4
Dependencies: 4DGL-uLCD-SE PinDetect
FarkleGame.h@0:bbda88bee65a, 2022-03-28 (annotated)
- Committer:
- lhanks02
- Date:
- Mon Mar 28 18:44:30 2022 +0000
- Revision:
- 0:bbda88bee65a
lab4
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lhanks02 | 0:bbda88bee65a | 1 | #include "mbed.h" |
lhanks02 | 0:bbda88bee65a | 2 | #define WHITE 0xFFFFFF |
lhanks02 | 0:bbda88bee65a | 3 | #include <stdlib.h> |
lhanks02 | 0:bbda88bee65a | 4 | #include <time.h> |
lhanks02 | 0:bbda88bee65a | 5 | #include "PinDetect.h" |
lhanks02 | 0:bbda88bee65a | 6 | #define NUM_DICE 6 |
lhanks02 | 0:bbda88bee65a | 7 | #include "Die.h" |
lhanks02 | 0:bbda88bee65a | 8 | |
lhanks02 | 0:bbda88bee65a | 9 | //#include "uLCD_4DGL.h" |
lhanks02 | 0:bbda88bee65a | 10 | //farkle game class, includes data members for a score and an array of die objects |
lhanks02 | 0:bbda88bee65a | 11 | class FarkleGame{ |
lhanks02 | 0:bbda88bee65a | 12 | |
lhanks02 | 0:bbda88bee65a | 13 | public: |
lhanks02 | 0:bbda88bee65a | 14 | FarkleGame(int num=0){ |
lhanks02 | 0:bbda88bee65a | 15 | score = num; |
lhanks02 | 0:bbda88bee65a | 16 | arr[0]=Die(0,0,42,42,WHITE); |
lhanks02 | 0:bbda88bee65a | 17 | arr[1]=Die(43,0,85,42,WHITE); |
lhanks02 | 0:bbda88bee65a | 18 | arr[2]=Die(85,0,127,42,WHITE); |
lhanks02 | 0:bbda88bee65a | 19 | arr[3]=Die(0,43,42,85,WHITE); |
lhanks02 | 0:bbda88bee65a | 20 | arr[4]=Die(43,43,85,85,WHITE); |
lhanks02 | 0:bbda88bee65a | 21 | arr[5]=Die(85,43,127,85,WHITE); |
lhanks02 | 0:bbda88bee65a | 22 | } |
lhanks02 | 0:bbda88bee65a | 23 | void startGame(); //function to display initial "roll 6 dice" |
lhanks02 | 0:bbda88bee65a | 24 | int getScore(); //function returning score |
lhanks02 | 0:bbda88bee65a | 25 | void setScore(int num); //function setting score |
lhanks02 | 0:bbda88bee65a | 26 | Die* getDieArray(); //getter for die array |
lhanks02 | 0:bbda88bee65a | 27 | int calcScore(int *numarray);//function to calculate score |
lhanks02 | 0:bbda88bee65a | 28 | void printScore();//print score function |
lhanks02 | 0:bbda88bee65a | 29 | void changeDieArray();//function to change die array |
lhanks02 | 0:bbda88bee65a | 30 | |
lhanks02 | 0:bbda88bee65a | 31 | private: |
lhanks02 | 0:bbda88bee65a | 32 | int score; |
lhanks02 | 0:bbda88bee65a | 33 | Die arr[NUM_DICE]; |
lhanks02 | 0:bbda88bee65a | 34 | }; |
lhanks02 | 0:bbda88bee65a | 35 | |
lhanks02 | 0:bbda88bee65a | 36 |