Francisco Martin / Mbed 2 deprecated MexicanStandoff

Dependencies:   SDFileSystem mbed-rtos mbed wave_player 4DGL-uLCD-SE PinDetect

Revision:
0:75716bd37804
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CPU.cpp	Mon Mar 14 03:04:08 2016 +0000
@@ -0,0 +1,40 @@
+#include "States.h"
+#include <stdlib.h>
+#include <time.h>
+#include <float.h>
+
+    
+
+CPU::CPU()
+{
+    difficulty = 1; 
+    srand(time(NULL));
+}
+
+CPU::CPU(int cpu_difficulty)
+{
+    difficulty = cpu_difficulty;
+    srand(time(NULL));
+}
+
+float CPU::shootTime()
+{
+    
+    int randNumber = rand() % 10;
+
+    float answer = (rand() % 10 + 1) / 10.0f;
+    return answer / (float) difficulty;       
+}
+
+bool CPU::shootAnswer(Prompt correctAnswer)
+{   
+    if(correctAnswer == Down || correctAnswer == Up)
+    {
+        int randNumber = rand() % 10;
+
+        if(randNumber == 9)
+            return false;
+    }
+    
+    return true;     
+}    
\ No newline at end of file