Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajout du scoreStyle #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/demand/DGameStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
*/
public class DGameStyle {
// ATTRIBUTS
private int type; // Num�ro contenant le Mode de jeu.
private String main_style;

// CONSTRUCTUEUR
public DGameStyle(int item)
public DGameStyle(String s1)
{
type = item;
main_style = s1;
}

// METHODE
/**
* Fonction retournant le num�ro du type de jeu dont il s'agit (En ligne | Hors ligne).
* @return type : entier repr�sentant le choix du type de jeu.
* Fonction retournant le numero du type de jeu dont il s'agit (En ligne | Hors ligne).
* @return type : entier representant le choix du type de jeu.
*/
public int getType()
public String getStyle()
{
return type;
return main_style;
}
}
4 changes: 2 additions & 2 deletions src/demand/Demand.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ public int getDLifeTime()
* Fonction retournant le choix pour le style de jeu
* @return dgst.DGameStyle() : int symbolisant un style de jeu.
*/
public int getGameStyle()
public String getGameStyle()
{
return (dgst ==null)? null:dgst.getType();
return (dgst ==null)? null:dgst.getStyle();
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void main(String[] args) {
new DBuyMethod(new DPrice(30, 70), 1),
new DDifficulty(2),
new DLifeTime(2),
new DGameStyle(0),
new DGameStyle("A-RPG"),
new DStoryType(0,2),
new DGameSupport(Construct, Name, type),
new DAccessory(Construct, Access, type),
Expand All @@ -59,7 +59,7 @@ public static void main(String[] args) {
new SBuyMethod(new SPrice(75), 1),
new SDifficulty(0),
new SLifeTime(0),
new SGameStyle(),
new SGameStyle("A-RPG"),
new SStoryType(),
new SGameSupport(construct2, name2, Type2),
new SAccessory(null, null, null)
Expand All @@ -76,7 +76,7 @@ public static void main(String[] args) {
new SPrice(45), 0),
new SDifficulty(1),
new SLifeTime(1),
new SGameStyle(),
new SGameStyle("MMORPG"),
new SStoryType(),
new SGameSupport(construct2, name2, Type2),
new SAccessory(null, null, null)
Expand All @@ -94,7 +94,7 @@ public static void main(String[] args) {
new SPrice(35), 0),
new SDifficulty(2),
new SLifeTime(2),
new SGameStyle(),
new SGameStyle("Fiction Int�ractive"),
new SStoryType(),
new SGameSupport(construct2, name2, Type2),
new SAccessory(null, null, null)
Expand All @@ -114,7 +114,7 @@ public static void main(String[] args) {
new SPrice(25), 1),
new SDifficulty(3),
new SLifeTime(3),
new SGameStyle(),
new SGameStyle("Visual Novels"),
new SStoryType(),
new SGameSupport(construct1, name1, Type1),
new SAccessory(null, null, null)
Expand All @@ -134,7 +134,7 @@ public static void main(String[] args) {
new SPrice(45), 1),
new SDifficulty(2),
new SLifeTime(2),
new SGameStyle(),
new SGameStyle("MMORPG"),
new SStoryType("Horreur", "Aventure"),
new SGameSupport(construct, name, Type),
new SAccessory(new String[] {"Nintendo", "Nintendo"," Microsoft"}, new String[] {"WiiMote","GamePad","Xbox360"}, new String[]{"Manette", "Manette", "Manette"})
Expand Down
43 changes: 43 additions & 0 deletions src/score/StyleScore.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package score;

import supply.DemandMethods;
import java.util.TreeMap;


public abstract class StyleScore extends Score<String>{

// Nom du Style de jeu => Groupe de Style principal, Groupe secondaire
private TreeMap<String,String> style_tree;
private String s_style;
private String d_style;

public StyleScore(String s1){
style_tree.put("Fiction Int�ractive", "Aventure, Sous-Aventure");
style_tree.put("Visual Novel", "Aventure, Sous-Aventure");
style_tree.put("Infiltration", "Action Aventure, Sous-Action, Sous-Aventure");
style_tree.put("Survival Horror", "Action Aventure, Sous-Action, Sous-Aventure");

// Styles de jeux de l'offre et de la demande
s_style = s1;
}
@Override
public abstract String extractD(DemandMethods myDemand);
@Override
public int getScore(DemandMethods myDemand) {
d_style = myDemand.getGameStyle();
if(s_style == d_style && style_tree.containsKey(s_style)) return score = 100;
else if(style_tree.containsKey(s_style) && style_tree.containsKey(d_style)){
String[] s_groups = style_tree.get(s_style).toLowerCase().split(", ");
String[] d_groups = style_tree.get(d_style).toLowerCase().split(", ");
for(int i = 0; i < s_groups.length;i++)System.out.println(s_groups[i]);
for(int i = 0; i < d_groups.length;i++)System.out.println(d_groups[i]);
if(s_groups[0].equals(d_groups[0])) return score = 50;
for(int i = 1; i < s_groups.length; i++)
for(int j = 1; j < d_groups.length;j++)
if(s_groups[i].equals(d_groups[j])) return score = 25;
}
return score = 0;

}
}

2 changes: 1 addition & 1 deletion src/supply/DemandMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public interface DemandMethods {
public int getDBuyMethod();
public int getDifficulty();
public int getDLifeTime();
public int getGameStyle();
public String getGameStyle();
public int[] getStoryType();
public Triplet<String, String, Integer>[] getGameSupportEquipements();
public Triplet<String, String, Integer>[] getAccessoryEquipements();
Expand Down
15 changes: 13 additions & 2 deletions src/supply/SGameStyle.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
package supply;

public class SGameStyle {
import score.StyleScore;

}
public class SGameStyle extends StyleScore{

public SGameStyle(String s1) {
super(s1);
}

public String extractD(DemandMethods myDemand) {
// TODO Auto-generated method stub
return myDemand.getGameStyle();
}

}
178 changes: 89 additions & 89 deletions src/supply/Supply.java
Original file line number Diff line number Diff line change
@@ -1,89 +1,89 @@
package supply;

import score.Score;

public class Supply {

// ATTRIBUTS
protected int score; // Score de l'offre par rapport � une demande.
protected int length_C; // Nombre de crit�re pr�sent dans l'offre.
private Score<?> criterion[]; // Ensemble des crit�res correspondant � l'offre.
private SPrice price;

// CONSTRUCTEUR
public Supply(STitle title, SDescription desc, SEditor edit, SMark mark, SReleaseDate rd, SGameType gm, SBuyMethod bm, SDifficulty diff, SLifeTime lt, SGameStyle gst, SStoryType st, SGameSupport gs, SAccessory acce)
{
length_C = 13;
criterion = new Score[length_C];

////////////////////////////////////////////
// A SUPPRIMER UNE FOIS GAMESTYLE OK !!!!!//
for(int i=0; i < length_C; i++) //
criterion[i] = null; //
////////////////////////////////////////////

price = bm.getPrice();

criterion[0] = title;
criterion[1] = desc;
criterion[2] = edit;
criterion[3] = mark;
criterion[4] = rd;
criterion[5] = gm;
criterion[6] = bm;
criterion[7] = diff;
criterion[8] = lt;
//criterion[9] = gst;
criterion[10]= st;
criterion[11]= gs;
criterion[12]= acce;
score = 0;
}

// METHODES
/**
* Fonction servant � comparer chaque crit�re de l'offre avec une demande
* @param myDemand : DemandMethods Interface impl�ment� par une demande.
*/
public void compare(DemandMethods myDemand)
{
for (int i=0; i< length_C; i++)
if(criterion[i]!= null)
score += criterion[i].getScore(myDemand);
}

/**
* Fonction retournant le score d'une offre
* @return score : int repr�sentant le score d'une offre.
*/
public int getScore()
{
return score;
}

/**
* Surd�finition de la m�thode toString() afin d'afficher le score de notre offre lors de l'affichage.
*/
public String toString()
{
return "\t- Title : "+criterion[0]
+"\n\t- Description : "+criterion[1]
+"\n\t- Editeur : "+criterion[2]
+"\n-------- -------- -------- -------- \n"
+"\n\t- Note : "+criterion[3]
+"\n\t- Date de sortie : "+criterion[4]
+"\n\t- Mode de jeu : "+criterion[5]
+"\n\t- Forme de paiement : "+criterion[6]
+"\n\t\t-Prix : "+price
+"\n-------- -------- -------- -------- \n"
+"\n\t- Difficult� : "+criterion[7]
+"\n\t- Dur�e de jeu : "+criterion[8]
+"\n\t- Style de jeu : "+criterion[9]
+"\n\t- Style d'histoire : "+criterion[10]
+"\n\t- Support possibles : "+criterion[11]
+"\n\t- Accessoires : "+criterion[12]
+"\n-------- -------- -------- -------- "
+"\n-------- Score : "+score+" -------- "
+"\n-------- -------- -------- -------- ";
}
}
package supply;
import score.Score;
public class Supply {
// ATTRIBUTS
protected int score; // Score de l'offre par rapport � une demande.
protected int length_C; // Nombre de crit�re pr�sent dans l'offre.
private Score<?> criterion[]; // Ensemble des crit�res correspondant � l'offre.
private SPrice price;
// CONSTRUCTEUR
public Supply(STitle title, SDescription desc, SEditor edit, SMark mark, SReleaseDate rd, SGameType gm, SBuyMethod bm, SDifficulty diff, SLifeTime lt, SGameStyle gst, SStoryType st, SGameSupport gs, SAccessory acce)
{
length_C = 13;
criterion = new Score[length_C];
////////////////////////////////////////////
// A SUPPRIMER UNE FOIS GAMESTYLE OK !!!!!//
for(int i=0; i < length_C; i++) //
criterion[i] = null; //
////////////////////////////////////////////
price = bm.getPrice();
criterion[0] = title;
criterion[1] = desc;
criterion[2] = edit;
criterion[3] = mark;
criterion[4] = rd;
criterion[5] = gm;
criterion[6] = bm;
criterion[7] = diff;
criterion[8] = lt;
criterion[9] = gst;
criterion[10]= st;
criterion[11]= gs;
criterion[12]= acce;
score = 0;
}
// METHODES
/**
* Fonction servant � comparer chaque crit�re de l'offre avec une demande
* @param myDemand : DemandMethods Interface impl�ment� par une demande.
*/
public void compare(DemandMethods myDemand)
{
for (int i=0; i< length_C; i++)
if(criterion[i]!= null)
score += criterion[i].getScore(myDemand);
}
/**
* Fonction retournant le score d'une offre
* @return score : int repr�sentant le score d'une offre.
*/
public int getScore()
{
return score;
}
/**
* Surd�finition de la m�thode toString() afin d'afficher le score de notre offre lors de l'affichage.
*/
public String toString()
{
return "\t- Title : "+criterion[0]
+"\n\t- Description : "+criterion[1]
+"\n\t- Editeur : "+criterion[2]
+"\n-------- -------- -------- -------- \n"
+"\n\t- Note : "+criterion[3]
+"\n\t- Date de sortie : "+criterion[4]
+"\n\t- Mode de jeu : "+criterion[5]
+"\n\t- Forme de paiement : "+criterion[6]
+"\n\t\t-Prix : "+price
+"\n-------- -------- -------- -------- \n"
+"\n\t- Difficult� : "+criterion[7]
+"\n\t- Dur�e de jeu : "+criterion[8]
+"\n\t- Style de jeu : "+criterion[9]
+"\n\t- Style d'histoire : "+criterion[10]
+"\n\t- Support possibles : "+criterion[11]
+"\n\t- Accessoires : "+criterion[12]
+"\n-------- -------- -------- -------- "
+"\n-------- Score : "+score+" -------- "
+"\n-------- -------- -------- -------- ";
}
}