ELEC2645 (2018/19) / Mbed 2 deprecated EL17MCD

Dependencies:   mbed

Revision:
17:cb39d9fa08dc
Parent:
16:a2c945279b79
Child:
21:44e87d88afe2
--- a/Scores/Scores.cpp	Wed Apr 24 13:44:12 2019 +0000
+++ b/Scores/Scores.cpp	Sat Apr 27 17:43:46 2019 +0000
@@ -7,9 +7,9 @@
 
 Scores::Scores()
 {
-    _top_three[0] = 0;
-    _top_three[1] = 0;
-    _top_three[2] = 0;
+  _top_three[0] = 0;
+  _top_three[1] = 0;
+  _top_three[2] = 0;
 }
 
 Scores::~Scores()
@@ -19,47 +19,45 @@
 
 float Scores::score_calculator(int turns, int health)
 {
-    float new_score = health * 100 / turns;
-    _add_to_top_scores(new_score);
-    return new_score;
+  float new_score = health * 100 / turns;
+  _add_to_top_scores(new_score);
+  return new_score;
 }
 
 void Scores::display_score(float current, N5110 &lcd)
 {
-    char buffer[14]; 
-    sprintf(buffer, "%.0f", current); 
-    lcd.printString(" Score :", 10, 4); 
-    lcd.printString(buffer, 60, 4);
+  char buffer[14]; 
+  sprintf(buffer, "%.0f", current); 
+  lcd.printString(" Score :", 10, 4); 
+  lcd.printString(buffer, 60, 4);
 }  
 
 void Scores::display_top_scores(N5110 &lcd)
 {
-    char buffer[14]; 
-    sprintf(buffer, "%.0f", _top_three[0]); 
-    lcd.printString(" 1. ", 15, 2); 
-    lcd.printString(buffer, 45, 2);
+  char buffer[14]; 
+  sprintf(buffer, "%.0f", _top_three[0]); 
+  lcd.printString(" 1. ", 15, 2); 
+  lcd.printString(buffer, 45, 2);
     
-    sprintf(buffer, "%.0f", _top_three[1]); 
-    lcd.printString(" 2. ", 15, 3); 
-    lcd.printString(buffer, 45, 3);
+  sprintf(buffer, "%.0f", _top_three[1]); 
+  lcd.printString(" 2. ", 15, 3); 
+  lcd.printString(buffer, 45, 3);
     
-    sprintf(buffer, "%.0f", _top_three[2]); 
-    lcd.printString(" 3. ", 15, 4); 
-    lcd.printString(buffer, 45, 4);
+  sprintf(buffer, "%.0f", _top_three[2]); 
+  lcd.printString(" 3. ", 15, 4); 
+  lcd.printString(buffer, 45, 4);
 }     
 
 void Scores::_add_to_top_scores(float new_score)
 {
-    if (new_score > _top_three[0]) { 
-        _top_three[2] = _top_three[1];
-        _top_three[1] = _top_three[0];
-        _top_three[0] = new_score; 
-    }
-    else if (new_score > _top_three[1]) {
-        _top_three[2] = _top_three[1];
-        _top_three[1] = new_score; 
-    }
-    else if (new_score > _top_three[2]) { 
-        _top_three[2] = new_score; 
-    }    
+  if (new_score > _top_three[0]) { 
+    _top_three[2] = _top_three[1];
+    _top_three[1] = _top_three[0];
+    _top_three[0] = new_score; 
+  } else if (new_score > _top_three[1]) {
+    _top_three[2] = _top_three[1];
+    _top_three[1] = new_score; 
+  } else if (new_score > _top_three[2]) { 
+    _top_three[2] = new_score; 
+  }    
 }