# TP4 : Génie Logiciel ## Conception et développement et métrique ~~~~ Alif Aizat MOHD NOOR Licence 2 Informatique Université de La Rochelle 15/10/2019 ~~~~ ### 1. Diagram de classe ![](https://i.imgur.com/vuohFV8.png) ### 2. Les valeurs des métriques orientées objet (sous forme tabulaire) pour ce diagramme | Classe | AC | EC | I= EC(AC + EC) | | -------- | ------| ------| -------------- | | Client | 2 | 1 | 1/3 ~ 0,33 | | Particulier | 0 | 1 | 1 | | Entreprise | 0 | 1 | 1 | | Restaurateur| 1 | 0 | 0 | | Restaurant | 1 | 3 | 3/4 = 0,75 | | Reservation | 1 | 1 | 1/2 = 0,5 | | Table | 1 | 0 | 0 | Les valeurs métriques des classes Particulier, Entreprise ne sont pas acceptables et ces classes ne sont vraiement pas stables. ### 3. Le code java de toutes les classes #### Package : Client Client.java ```java = /* * Copyright (C) 2019 alifaizat * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package tp4genlog.client; import java.util.ArrayList; import java.util.List; import tp4genlog.restaurant.Restaurant; /** * * @author alifaizat */ public abstract class Client { /** * La liste des restaurants pour le client. */ protected List<Restaurant> restaurants; /** * Le nom de client. */ protected String nom; /** * le numero téléphone de client. */ protected String telephone; /** * L'etat de client. BANNI ou ACCEPTE. */ protected EtatClient etat; /** * Constructeur pour la class abstraite Client. * * @param nom * @param telephone */ public Client(final String nom, final String telephone) { this.nom = nom; this.telephone = telephone; this.restaurants = new ArrayList<>(); this.etat = EtatClient.ACCEPTE; } /** * Ajouter un restaurant dans la liste des restraurant. * * @param restaurant */ public abstract void addRestaurants(Restaurant restaurant); /** * Modifier l'état de client. * @param etat */ public abstract void setEtat(EtatClient etat); } ``` <br> EtatClient.java ```java= /* * Copyright (C) 2019 alifaizat * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package tp4genlog.client; /** * * @author alifaizat */ public enum EtatClient { BANNI, ACCEPTE; } ``` <br> Particulier.java ```java= /* * Copyright (C) 2019 alifaizat * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package tp4genlog.client; import java.util.List; import tp4genlog.restaurant.Restaurant; /** * * @author alifaizat */ public class Particulier extends Client { /** * Le prenom de client particulier. */ private String prenom; /** * Constructeur pour la classe Particulier. * @param prenom * @param nom * @param telephone */ public Particulier(final String prenom,final String nom,final String telephone) { super(nom, telephone); this.prenom = prenom; } @Override public final void addRestaurants(final Restaurant restaurant) { this.restaurants.add(restaurant); } @Override public final void setEtat(final EtatClient etat) { this.etat = etat; } } ``` <br> Entreprise.java ```java= /* * Copyright (C) 2019 alifaizat * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package tp4genlog.client; import tp4genlog.restaurant.Restaurant; /** * * @author alifaizat */ public class Entreprise extends Client { /** * Constructeur pour la classe Entreprise. * @param nom * @param telephone */ public Entreprise(final String nom,final String telephone) { super(nom, telephone); } /** * Ajouter un restaurant dans la liste des restraurant. * @param restaurant */ @Override public final void addRestaurants(Restaurant restaurant){ this.restaurants.add(restaurant); } /** * Modifier l'état de client. * @param etat */ @Override public final void setEtat(final EtatClient etat) { this.etat = etat; } } ``` <br> #### Package Restaurant Restaurateur.java ```java= /* * Copyright (C) 2019 alifaizat * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package tp4genlog.restaurant; import tp4genlog.client.Client; /** * * @author alifaizat */ public interface Restaurateur { /** * Ajouter un client dans la liste des clients. * @param c */ void ajouterClient(Client c); /** * Ajouter une réservation dans la liste des résevartions. * @param r */ void ajouterReservation(Reservation r); /** * Bannir un client qui ne s’étant pas présenté au restaurant après * une réservation. * @param c */ void bannirClient(Client c); /** * Quitter. */ void quitter(); } ``` <br> Restaurant.java ```java= /* * Copyright (C) 2019 alifaizat * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package tp4genlog.restaurant; import java.util.ArrayList; import java.util.List; import tp4genlog.client.Client; import tp4genlog.client.EtatClient; /** * * @author alifaizat */ public class Restaurant implements Restaurateur { /** * Le nom de restaurant. */ private String nom; /** * Les tables dans le restaurant. */ private List<Table> tables; /** * La liste des réservations crées dans le restaurant. */ private List<Reservation> reservations; /** * La liste des clients. */ private List<Client> clients; /** * Le constructeur pour la classe Restaurant. * @param nom */ public Restaurant(final String nom) { this.nom = nom; this.tables = new ArrayList<>(); this.reservations = new ArrayList<>(); this.clients = new ArrayList<>(); } @Override public final void ajouterClient(Client c) { this.clients.add(c); } @Override public final void ajouterReservation(Reservation r) { this.reservations.add(r); } @Override public final void bannirClient(Client c) { c.setEtat(EtatClient.BANNI); } @Override public final void quitter() { System.out.println("Quitter"); } } ``` <br> TypeTable.java ```java= /* * Copyright (C) 2019 alifaizat * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package tp4genlog.restaurant; /** * * @author alifaizat */ public enum TypeTable { /** * Table a deux couverts. */ DEUX_COUVERTS, /** * Table a quatre couverts. */ QUARTE_COUVERTS; } ``` <br> Table.java ```java= /* * Copyright (C) 2019 alifaizat * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package tp4genlog.restaurant; /** * * @author alifaizat */ public class Table { /** * L'ID de la table. */ private int identifiant; /** * Le nombre de couvert qu'il possède. */ private int nbCouvert; /** * Le type de la table. */ private TypeTable type; /** * Pour résoudere le problem de "Magic Number". */ private static final int DEUX = 2; /** * Pour résoudere le problem de "Magic Number". */ private static final int QUATRE = 4; /** * Constructeur pour la classe Table. * @param identifiant * @param type */ public Table(final int identifiant,final TypeTable type) { this.identifiant = identifiant; this.type = type; if (this.type == TypeTable.DEUX_COUVERTS) { this.nbCouvert = DEUX; } else { this.nbCouvert = QUATRE; } } } ``` <br> Reservation.java ```java= /* * Copyright (C) 2019 alifaizat * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package tp4genlog.restaurant; import java.time.LocalDateTime; import java.util.Date; import java.util.List; import tp4genlog.client.Client; /** * * @author alifaizat */ public class Reservation { /** * La(les) table(s) affectée(s) à la réservation. */ private List<Table> tablesAffectees; /** * Nb max personne pour la réservation. */ private static final int NB_PERSONNE_MAX = 10; /** * Nb max d'heure de repas. */ private static final int DUREE_REPAS = 2; /** * Le client qui a fait la réservation. */ private Client client; /** * La date de la réservation. */ private Date date; /** * L'heure de la réservation. */ private LocalDateTime heure; /** * Numére d'odre de la réservation. */ private int ordre; /** * Constructeur pour la classe Reservation. * @param client * @param date * @param heure * @param ordre */ public Reservation(final Client client,final Date date, final LocalDateTime heure,final int ordre) { this.client = client; this.date = date; this.heure = heure; this.ordre = ordre; } /** * Faire la réservation des tables. */ public void reserverTable(){ } } ``` <br> <br> <a href="https://hackmd.io/@AlifAizat/BJLrHXXKS">Lien vers le fichier en ligne</a>