Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Materiel {
- private String ref;
- private int quantite;
- private float achat;
- protected float prixVente;
- private Fournisseur leFournisseur;
- public Materiel(String r, float pa){
- ref = r;
- achat = pa;
- }
- public void livrer(float q){
- quantite -= q;
- }
- public void stoquer(float q){
- quantite += q;
- }
- public void fournir(Fournisseur f){
- leFournisseur = f;
- }
- public void afficher(){
- String newLine = "\n";
- System.out.println(ref + newLine + quantite + newLine +
- achat + newLine + prixVente + newLine + leFournisseur);
- }
- @Override
- public String toString(){
- String newLine = "\n";
- return (ref + newLine + quantite + newLine +
- achat + newLine + prixVente + newLine + leFournisseur);
- }
- }
- public class MaterielEnPromotion extends Materiel {
- private String typeDePromo;
- private int pourcentageReduction;
- public MaterielEnPromotion(String r, float pa, String type, int pourcentage) {
- super(r, pa);
- typeDePromo = type;
- pourcentageReduction = pourcentage;
- }
- @Override
- public String toString(){
- String newLine = "\n";
- return(super.toString() + typeDePromo + newLine + pourcentageReduction);
- }
- }
- public class Fournisseur {
- private String nom, adresse;
- public Fournisseur(String nom, String adr){
- this.nom = nom;
- adresse = adr;
- }
- public String getNom() {
- return nom;
- }
- public String getAdresse() {
- return adresse;
- }
- @Override
- public String toString(){
- String newLine = "\n";
- return(nom + newLine + adresse);
- }
- }
- public class Main {
- public static void main(String[] args) {
- Fournisseur fourn = new Fournisseur("scoop", "Ezzahra");
- MaterielEnPromotion mat = new MaterielEnPromotion("Mac M1", 1000F, "Remise a la caisse", 30);
- mat.prixVente = 1300;
- mat.fournir(fourn);
- System.out.println(mat);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement