commit 9efb06a5f3505523cde5cf27f5320211c8e29e85
parent fda5ca174f6efdf7d5e70a28c4f47196a9e37a08
Author: John Charron <rm_rf_windows@yahoo.fr>
Date: Wed, 2 Feb 2011 09:49:44 +0100
Seance de travail, ajout de TotalScore et WordScore (jc)
Diffstat:
9 files changed, 168 insertions(+), 72 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1 +1,2 @@
-.DS_Store
-\ No newline at end of file
+.DS_Store
+code.zip
diff --git a/code/PtiClic/src/org/pticlic/Score.java b/code/PtiClic/src/org/pticlic/Score.java
@@ -1,8 +1,7 @@
package org.pticlic;
import org.pticlic.model.Constant;
-import org.pticlic.model.DownloadedScore;
-import org.pticlic.model.GamePlayed;
+import org.pticlic.model.Match;
import org.pticlic.model.Network;
import org.pticlic.model.Network.Mode;
@@ -21,7 +20,7 @@ import android.widget.Button;
*/
public class Score extends Activity implements OnClickListener{
- private GamePlayed gamePlayed;
+ private Match gamePlayed;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -36,7 +35,7 @@ public class Score extends Activity implements OnClickListener{
if (getIntent().getExtras() != null) {
// Pour JC : GamePlayed contient toutes les infos sur la partie jouee
- this.gamePlayed = (GamePlayed) getIntent().getExtras().get(Constant.SCORE_GAMEPLAYED);
+ this.gamePlayed = (Match) getIntent().getExtras().get(Constant.SCORE_GAMEPLAYED);
mode = (Mode) getIntent().getExtras().get(Constant.SCORE_MODE);
}
diff --git a/code/PtiClic/src/org/pticlic/games/BaseGame.java b/code/PtiClic/src/org/pticlic/games/BaseGame.java
@@ -4,7 +4,7 @@ import org.pticlic.R;
import org.pticlic.Score;
import org.pticlic.model.Constant;
import org.pticlic.model.DownloadedGame;
-import org.pticlic.model.GamePlayed;
+import org.pticlic.model.Match;
import org.pticlic.model.Network;
import org.pticlic.model.Relation;
import org.pticlic.model.Network.Mode;
@@ -41,7 +41,7 @@ public class BaseGame extends Activity implements OnClickListener {
private int currentWord = 0;
private int nbWord = 0;
private DownloadedGame game;
- private GamePlayed gamePlayed;
+ private Match gamePlayed;
/** Called when the activity is first created. */
@Override
@@ -62,7 +62,7 @@ public class BaseGame extends Activity implements OnClickListener {
nbWord = game.getNbWord();
// On initialise la partie.
- gamePlayed = new GamePlayed();
+ gamePlayed = new Match();
gamePlayed.setGame(game);
Relation r = Relation.getInstance();
diff --git a/code/PtiClic/src/org/pticlic/model/DownloadedScore.java b/code/PtiClic/src/org/pticlic/model/DownloadedScore.java
@@ -1,11 +0,0 @@
-package org.pticlic.model;
-
-/**
- * @author Bertrand BRUN
- *
- * Classe metier reprensentant le score sous forme json envoyer par le serveur.
- *
- */
-public class DownloadedScore {
-
-}
diff --git a/code/PtiClic/src/org/pticlic/model/GamePlayed.java b/code/PtiClic/src/org/pticlic/model/GamePlayed.java
@@ -1,49 +0,0 @@
-package org.pticlic.model;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-
-/**
- * @author Bertrand BRUN
- *
- * Cette classe represente une partie joue.
- * Elle sera envoyer au serveur pour que celui-ci
- * puisse calculer le score obtenue.
- *
- */
-public class GamePlayed implements Serializable {
-
- private static final long serialVersionUID = 1L;
- private ArrayList<CharSequence> relation1;
- private ArrayList<CharSequence> relation2;
- private ArrayList<CharSequence> relation3;
- private ArrayList<CharSequence> relation4;
- private ArrayList<CharSequence> poubelle;
- private DownloadedGame game;
-
- public GamePlayed() {
- relation1 = new ArrayList<CharSequence>();
- relation2 = new ArrayList<CharSequence>();
- relation3 = new ArrayList<CharSequence>();
- relation4 = new ArrayList<CharSequence>();
- poubelle = new ArrayList<CharSequence>();
- }
-
- public void setGame(DownloadedGame game) {
- this.game = game;
- }
-
- public DownloadedGame getGame() {
- return game;
- }
-
- public void add(int relation, CharSequence word) {
- switch (relation) {
- case 1: relation1.add(word); break;
- case 2: relation2.add(word); break;
- case 3: relation3.add(word); break;
- case 4: relation4.add(word); break;
- default: poubelle.add(word); break;
- }
- }
-}
diff --git a/code/PtiClic/src/org/pticlic/model/Match.java b/code/PtiClic/src/org/pticlic/model/Match.java
@@ -0,0 +1,49 @@
+package org.pticlic.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+/**
+ * @author Bertrand BRUN
+ *
+ * Cette classe represente une partie joue.
+ * Elle sera envoyer au serveur pour que celui-ci
+ * puisse calculer le score obtenue.
+ *
+ */
+public class Match implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private ArrayList<CharSequence> relation1;
+ private ArrayList<CharSequence> relation2;
+ private ArrayList<CharSequence> relation3;
+ private ArrayList<CharSequence> relation4;
+ private ArrayList<CharSequence> poubelle;
+ private DownloadedGame game;
+
+ public Match() {
+ relation1 = new ArrayList<CharSequence>();
+ relation2 = new ArrayList<CharSequence>();
+ relation3 = new ArrayList<CharSequence>();
+ relation4 = new ArrayList<CharSequence>();
+ poubelle = new ArrayList<CharSequence>();
+ }
+
+ public void setGame(DownloadedGame game) {
+ this.game = game;
+ }
+
+ public DownloadedGame getGame() {
+ return game;
+ }
+
+ public void add(int relation, CharSequence word) {
+ switch (relation) {
+ case 1: relation1.add(word); break;
+ case 2: relation2.add(word); break;
+ case 3: relation3.add(word); break;
+ case 4: relation4.add(word); break;
+ default: poubelle.add(word); break;
+ }
+ }
+}
diff --git a/code/PtiClic/src/org/pticlic/model/Network.java b/code/PtiClic/src/org/pticlic/model/Network.java
@@ -138,8 +138,8 @@ public class Network {
* @param game La partie jouee par l'utilisateur
* @return Le score sous forme JSON.
*/
- public DownloadedScore sendGame(GamePlayed game) {
- DownloadedScore score = null;
+ public TotalScore sendGame(Match game) {
+ TotalScore score = null;
try {
URL url = new URL(this.serverURL);
URLConnection connection = url.openConnection();
@@ -155,7 +155,7 @@ public class Network {
JsonReader reader = new JsonReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
// TODO : A changer lorsque je serais exactement ce que renvoie le serveur.
- score = gson.fromJson(reader, DownloadedScore.class);
+ score = gson.fromJson(reader, TotalScore.class);
} catch (IOException e) {
return score;
diff --git a/code/PtiClic/src/org/pticlic/model/TotalScore.java b/code/PtiClic/src/org/pticlic/model/TotalScore.java
@@ -0,0 +1,45 @@
+package org.pticlic.model;
+
+/**
+ *
+ * @author John CHARRON
+ *
+ */
+
+public class TotalScore {
+
+ private TotalScore scoreTotal;
+ private WordScore scores;
+
+ public TotalScore() {
+ }
+
+ public TotalScore(TotalScore scoreTotal, WordScore wordscores) {
+ this.scoreTotal = scoreTotal;
+ this.scores = wordscores;
+ }
+
+ public TotalScore getScoreTotal() {
+ return scoreTotal;
+ }
+
+ public void setScoreTotal(TotalScore scoreTotal) {
+ this.scoreTotal = scoreTotal;
+ }
+
+ public WordScore getWordscores() {
+ return scores;
+ }
+
+ public void setWordscores(WordScore wordscores) {
+ this.scores = wordscores;
+ }
+
+ @Override
+ public String toString() {
+ return "TotalScore [scoreTotal=" + scoreTotal + ", wordscores="
+ + scores + "]";
+ }
+
+
+}
+\ No newline at end of file
diff --git a/code/PtiClic/src/org/pticlic/model/WordScore.java b/code/PtiClic/src/org/pticlic/model/WordScore.java
@@ -0,0 +1,62 @@
+package org.pticlic.model;
+
+/**
+ *
+ * @author John CHARRON
+ *
+ */
+
+public class WordScore {
+
+ private int idmot;
+ private double score;
+ private double probaR1;
+ private double probaR2;
+
+ public WordScore() {}
+
+ public WordScore(int idmot, double score, double probaR1, double probaR2) {
+ this.idmot = idmot;
+ this.score = score;
+ this.probaR1 = probaR1;
+ this.probaR2 = probaR2;
+ }
+
+ public int getIdmot() {
+ return idmot;
+ }
+
+ public void setIdmot(int idmot) {
+ this.idmot = idmot;
+ }
+
+ public double getScore() {
+ return score;
+ }
+
+ public void setScore(double score) {
+ this.score = score;
+ }
+
+ public double getProbaR1() {
+ return probaR1;
+ }
+
+ public void setProbaR1(double probaR1) {
+ this.probaR1 = probaR1;
+ }
+
+ public double getProbaR2() {
+ return probaR2;
+ }
+
+ public void setProbaR2(double probaR2) {
+ this.probaR2 = probaR2;
+ }
+
+ @Override
+ public String toString() {
+ return "WordScore [idmot=" + idmot + ", score=" + score + ", probaR1="
+ + probaR1 + ", probaR2=" + probaR2 + "]";
+ }
+}