diff --git a/src/demand/DGameStyle.java b/src/demand/DGameStyle.java index d0242cb..be84b24 100644 --- a/src/demand/DGameStyle.java +++ b/src/demand/DGameStyle.java @@ -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; } } diff --git a/src/demand/Demand.java b/src/demand/Demand.java index 6bc33a0..41b56ed 100644 --- a/src/demand/Demand.java +++ b/src/demand/Demand.java @@ -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(); } /** diff --git a/src/main/Main.java b/src/main/Main.java index 09191fe..c59d385 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -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), @@ -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) @@ -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) @@ -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) @@ -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) @@ -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"}) diff --git a/src/score/StyleScore.java b/src/score/StyleScore.java new file mode 100644 index 0000000..194c2fb --- /dev/null +++ b/src/score/StyleScore.java @@ -0,0 +1,43 @@ +package score; + +import supply.DemandMethods; +import java.util.TreeMap; + + +public abstract class StyleScore extends Score{ + + // Nom du Style de jeu => Groupe de Style principal, Groupe secondaire + private TreeMap 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; + + } +} + diff --git a/src/supply/DemandMethods.java b/src/supply/DemandMethods.java index b9dc7c4..d77645b 100644 --- a/src/supply/DemandMethods.java +++ b/src/supply/DemandMethods.java @@ -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[] getGameSupportEquipements(); public Triplet[] getAccessoryEquipements(); diff --git a/src/supply/SGameStyle.java b/src/supply/SGameStyle.java index f434039..42bb8dc 100644 --- a/src/supply/SGameStyle.java +++ b/src/supply/SGameStyle.java @@ -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(); + } + +} \ No newline at end of file diff --git a/src/supply/Supply.java b/src/supply/Supply.java index 101c16d..313bcdb 100644 --- a/src/supply/Supply.java +++ b/src/supply/Supply.java @@ -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-------- -------- -------- -------- "; + } +}