www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 3b2f879c277541d2e28257e002b092201564584b
parent d5e18a87094260df04f94f0ad7aafdd6c7141834
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date:   Wed,  2 Feb 2011 11:33:58 +0100

Merge branch 'master' of https://github.com/jsmaniac/2011-m1s2-ter

Diffstat:
M.gitignore | 4++--
Mcode/PtiClic/res/layout/game.xml | 38++++++++++++++++++++++----------------
Mcode/PtiClic/src/org/pticlic/Score.java | 7+++----
Mcode/PtiClic/src/org/pticlic/games/BaseGame.java | 11+++++++----
Dcode/PtiClic/src/org/pticlic/model/DownloadedScore.java | 11-----------
Dcode/PtiClic/src/org/pticlic/model/GamePlayed.java | 49-------------------------------------------------
Acode/PtiClic/src/org/pticlic/model/Match.java | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Mcode/PtiClic/src/org/pticlic/model/Network.java | 6+++---
Acode/PtiClic/src/org/pticlic/model/TotalScore.java | 46++++++++++++++++++++++++++++++++++++++++++++++
Acode/PtiClic/src/org/pticlic/model/WordScore.java | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10 files changed, 194 insertions(+), 89 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/res/layout/game.xml b/code/PtiClic/res/layout/game.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout android:id="@+id/widget29" - android:layout_width="fill_parent" android:layout_height="fill_parent" - android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"> +<LinearLayout android:layout_width="fill_parent" + android:layout_height="fill_parent" android:orientation="vertical" + xmlns:android="http://schemas.android.com/apk/res/android"> <LinearLayout android:id="@+id/widget40" android:layout_width="fill_parent" android:layout_height="fill_parent" @@ -15,27 +15,33 @@ android:layout_height="wrap_content" android:text="currentWord" android:textStyle="bold" android:gravity="center"> </TextView> - + </LinearLayout> - <LinearLayout android:id="@+id/widget44" - android:orientation="horizontal" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="9"> + <LinearLayout android:orientation="horizontal" + android:layout_height="fill_parent" android:layout_width="fill_parent" + android:layout_weight="9"> - <Button android:id="@+id/relation1" - android:text="relation1" android:layout_height="wrap_content" android:layout_weight="1" android:layout_width="fill_parent" android:layout_gravity="bottom"> + <Button android:id="@+id/relation1" android:text="relation1" + android:layout_height="wrap_content" android:layout_weight="1" + android:layout_width="fill_parent" android:layout_gravity="bottom"> </Button> - <Button android:id="@+id/relation2" - android:text="relation2" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1" android:layout_gravity="bottom"> + <Button android:id="@+id/relation2" android:text="relation2" + android:layout_height="wrap_content" android:layout_width="fill_parent" + android:layout_weight="1" android:layout_gravity="bottom"> </Button> - <Button android:id="@+id/poubelle" - android:text="poubelle" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1" android:layout_gravity="bottom"> + <Button android:id="@+id/trash" android:text="trash" + android:layout_height="wrap_content" android:layout_width="fill_parent" + android:layout_weight="1" android:layout_gravity="bottom"> </Button> - <Button android:id="@+id/relation3" - android:text="relation3" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1" android:layout_gravity="bottom"> + <Button android:id="@+id/relation3" android:text="relation3" + android:layout_height="wrap_content" android:layout_width="fill_parent" + android:layout_weight="1" android:layout_gravity="bottom"> </Button> - <Button android:id="@+id/relation4" - android:text="relation4" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1" android:layout_gravity="bottom"> + <Button android:id="@+id/relation4" android:text="relation4" + android:layout_height="wrap_content" android:layout_width="fill_parent" + android:layout_weight="1" android:layout_gravity="bottom"> </Button> </LinearLayout> 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(); @@ -74,7 +74,9 @@ public class BaseGame extends Activity implements OnClickListener { Button r4 = ((Button)findViewById(R.id.relation4)); // TODO : Pour l'instant la poubelle ne fait rien. Il faudra certainement la ranger dans un categorie dans GamePlayed pour calculer le score. - ((Button)findViewById(R.id.poubelle)).setText("Poubelle"); + Button trash = ((Button)findViewById(R.id.trash)); + trash.setOnClickListener(this); + trash.setText("poubelle"); // Écoute des clics sur les relations if (nbrel > 0) { r1.setOnClickListener(this); r1.setText(r.getRelationName(game.getCat1())); } else { r1.setVisibility(View.GONE); } @@ -167,6 +169,7 @@ public class BaseGame extends Activity implements OnClickListener { case (R.id.relation2) : gamePlayed.add(2, currentWord); next(); break; case (R.id.relation3) : gamePlayed.add(3, currentWord); next(); break; case (R.id.relation4) : gamePlayed.add(4, currentWord); next(); break; + case (R.id.trash) : gamePlayed.add(0, currentWord); next(); break; } } } \ No newline at end of file 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 + "]"; + } +}