Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. package commandes;
  2.  
  3.  
  4. /**
  5.  * @author ouziri
  6.  * @version 1.0
  7.  *
  8.  */
  9.  
  10. public class Commande implements ICommande {
  11.    
  12.     private double montant ;
  13.     private double poids ;
  14.     private ICoutLiv coutLiv;
  15.    
  16.     public Commande(double montant, double poids) {    
  17.         assert montant > 0 && poids > 0;
  18.         this.montant = montant;
  19.         this.poids = poids;    
  20.         coutLiv = new CoutLivAuMontant();
  21.     }
  22.    
  23.     public double calculerCoutLivraison () {
  24.         return coutLiv.calculerCoutLivraison(this);
  25.     }
  26.  
  27.     public double getMontant() {
  28.         return montant;
  29.     }
  30.  
  31.     public double getPoids() {
  32.         return poids;
  33.     }
  34. }
  35.  
  36. package commandes;
  37.  
  38. public interface ICoutLiv {
  39.  
  40.     double calculerCoutLivraison(ICommande commande);
  41.  
  42. }
  43.  
  44. package commandes;
  45.  
  46. public class CoutLivAuMontant implements ICoutLiv {
  47.     private static double tauxLivraison = 0.1;
  48.  
  49.     @Override
  50.     public double calculerCoutLivraison(ICommande c) {
  51.         return c.getMontant() * tauxLivraison;
  52.        
  53.     }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement