Advertisement
bltijo

Untitled

Oct 23rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. public class QualityControl {
  2.  
  3.  
  4.     public static void main(String[] args) {
  5.         QualityControl qc = new QualityControl();
  6.         final Product engrais = new Product();
  7.         final Product medicaments = new Product();
  8.         qc.controlQuality(engrais, Country.USA);
  9.         qc.controlQuality(medicaments, Country.JAPAN);
  10.     }
  11.  
  12.     public Map<Country, Procedure> procedures;
  13.  
  14.     public QualityControl() {
  15.         this.procedures = new HashMap<>();
  16.         procedures.put(Country.USA, product -> System.out.println("American Method ! "));
  17.         procedures.put(Country.JAPAN, product -> System.out.println("Japan Method (two time longer than USA) ! "));
  18.         procedures.put(Country.CHINA, product -> System.out.println("What is quality control ??"));
  19.     }
  20.  
  21.     public void controlQuality(Product product, Country country){
  22.          procedures
  23.             .get(country)
  24.             .accept(product);
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement