Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package commandes;
- /**
- * @author ouziri
- * @version 1.0
- *
- */
- public class Commande implements ICommande {
- private double montant ;
- private double poids ;
- private ICoutLiv coutLiv;
- public Commande(double montant, double poids) {
- assert montant > 0 && poids > 0;
- this.montant = montant;
- this.poids = poids;
- coutLiv = new CoutLivAuMontant();
- }
- public double calculerCoutLivraison () {
- return coutLiv.calculerCoutLivraison(this);
- }
- public double getMontant() {
- return montant;
- }
- public double getPoids() {
- return poids;
- }
- }
- package commandes;
- public interface ICoutLiv {
- double calculerCoutLivraison(ICommande commande);
- }
- package commandes;
- public class CoutLivAuMontant implements ICoutLiv {
- private static double tauxLivraison = 0.1;
- @Override
- public double calculerCoutLivraison(ICommande c) {
- return c.getMontant() * tauxLivraison;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement