Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class QualityControl {
- public static void main(String[] args) {
- QualityControl qc = new QualityControl();
- final Product engrais = new Product();
- final Product medicaments = new Product();
- qc.controlQuality(engrais, Country.USA);
- qc.controlQuality(medicaments, Country.JAPAN);
- }
- public Map<Country, Procedure> procedures;
- public QualityControl() {
- this.procedures = new HashMap<>();
- procedures.put(Country.USA, product -> System.out.println("American Method ! "));
- procedures.put(Country.JAPAN, product -> System.out.println("Japan Method (two time longer than USA) ! "));
- procedures.put(Country.CHINA, product -> System.out.println("What is quality control ??"));
- }
- public void controlQuality(Product product, Country country){
- procedures
- .get(country)
- .accept(product);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement