Commit 72f951a4 authored by rakam's avatar rakam

Updates FileManager for use with Point

parent 9698d737
......@@ -10,20 +10,19 @@ import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
/**
* Created by spyrit on 12/11/14.
*/
public class FileManager {
/* Création du fichier */
/* S:0:1:46 */
public static void createFile(Context context, int typeAutomate, int service, int side, int idMatch) {
deleteFile(context);
String r = null;
String r;
if (idMatch < 10) {
r = "0" + Integer.toString(idMatch);
} else {
r = Integer.toString(idMatch);
}
if (typeAutomate == 0) {
WriteScore(context, "S" + Integer.toString(service) + Integer.toString(side) + r);
} else if (typeAutomate == 1) {
......@@ -35,8 +34,8 @@ public class FileManager {
}
/* Le joueur A ou B marque un point */
public static void point(Context context, int point) {
WriteScore(context, Integer.toString(point));
public static void point(Context context, Point point) {
WriteScore(context, point.getBackupString());
}
/* Initialiser un nouvel automate */
......@@ -61,10 +60,11 @@ public class FileManager {
aut = new AutomateDoublePro(context, service, side == 1, idMatch, false);
}
for (int i = 5; i < s.length(); i++) {
aut.point2(Character.getNumericValue(s.charAt(i)));
String[] backupPoints = s.split("!");
for (int i = 1; i < backupPoints.length; i++) {
Stats stats = Stats.createFromBackup(backupPoints[i]);
aut.pointWithoutSaving(stats);
}
return aut;
}
......@@ -115,6 +115,7 @@ public class FileManager {
}
public static String ReadScore(Context context) {
FileReader fileReader;
BufferedReader bufferedReader;
......@@ -148,11 +149,11 @@ public class FileManager {
public static void deleteLast(Context context) {
String s = ReadScore(context);
if (s.length() > 5) {
s = s.substring(0, s.length() - 1);
int startLastElement = s.lastIndexOf("!");
if (startLastElement != -1) {
deleteFile(context);
WriteScore(context, s.substring(0, startLastElement));
}
deleteFile(context);
WriteScore(context, s);
}
public static boolean fileExist(Context context) {
......
package fr.istic.masteru.android.automate;
/**
* Created by matthias on 11/03/15.
*/
public class Step {
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment