Seance de travail, ajout de TotalScore et WordScore (jc)
This commit is contained in:
parent
fda5ca174f
commit
9efb06a5f3
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
.DS_Store
|
||||
.DS_Store
|
||||
code.zip
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 {
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@ import java.util.ArrayList;
|
|||
* puisse calculer le score obtenue.
|
||||
*
|
||||
*/
|
||||
public class GamePlayed implements Serializable {
|
||||
public class Match implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private ArrayList<CharSequence> relation1;
|
||||
|
@ -21,7 +21,7 @@ public class GamePlayed implements Serializable {
|
|||
private ArrayList<CharSequence> poubelle;
|
||||
private DownloadedGame game;
|
||||
|
||||
public GamePlayed() {
|
||||
public Match() {
|
||||
relation1 = new ArrayList<CharSequence>();
|
||||
relation2 = new ArrayList<CharSequence>();
|
||||
relation3 = new ArrayList<CharSequence>();
|
|
@ -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;
|
||||
|
|
45
code/PtiClic/src/org/pticlic/model/TotalScore.java
Normal file
45
code/PtiClic/src/org/pticlic/model/TotalScore.java
Normal file
|
@ -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 + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
62
code/PtiClic/src/org/pticlic/model/WordScore.java
Normal file
62
code/PtiClic/src/org/pticlic/model/WordScore.java
Normal file
|
@ -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 + "]";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user