Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Medicament
- {
- public Medicament(String nom, String effet, String posologie, double prixProd, double prixFinal)
- {
- this.nom = nom;
- this.effet = effet;
- this.posologie = posologie;
- if (prixProd > 0)
- {
- this.prixProd = prixProd;
- }
- else
- {
- this.prixProd = 0;
- }
- if (prixFinal >= prixProd)
- {
- this.prixFinal = prixFinal;
- }
- else
- {
- this.prixFinal = 0;
- }
- }
- public Medicament()
- {
- this("None", "None", "None", 0, 0);
- }
- public String toString()
- {
- return "Médicament : " + nom
- + "\n Effet : " + effet + "\n A prendre " + posologie
- + " fois par jour.\n Prix de production : " + prixProd
- + " €\n Prix de consomation : " + prixFinal + " €\n";
- }
- public void setPosologie(String newPosologie)
- {
- posologie = newPosologie;
- }
- public void setEffet(String newEffet)
- {
- effet = newEffet;
- }
- public void setPrixProd(double newPrixProd)
- {
- if (newPrixProd > 0)
- {
- this.prixProd = newPrixProd;
- }
- }
- public void setPrixFinal(double newPrixFinal)
- {
- if (newPrixFinal > prixProd)
- {
- this.prixFinal = newPrixFinal;
- }
- }
- public String getNom() { return nom;}
- public String getEffet() { return effet;}
- public String getPosologie() { return posologie;}
- public double getPrixProd() { return prixProd;}
- public double getPrixFinal() { return prixFinal;}
- public void printAll()
- {
- System.out.println(this);
- }
- public void printSynt()
- {
- System.out.println("Le médicament " + nom + " a comme effet de " + effet + " et se vend au prix de " + prixFinal + "€");
- }
- public double marge()
- {
- return prixFinal - prixProd;
- }
- public double percent()
- {
- return marge() / prixProd * 100;
- }
- private String nom;
- private String effet;
- private String posologie;
- private double prixProd;
- private double prixFinal;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement