Merge branch 'master' of https://github.com/jsmaniac/2011-m1s2-ter
This commit is contained in:
commit
3b2f879c27
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
.DS_Store
|
||||
.DS_Store
|
||||
code.zip
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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