|
| 1 | +package com.premaseem; |
| 2 | + |
| 3 | +import java.util.Scanner; |
| 4 | + |
| 5 | +/* |
| 6 | +@author: Aseem Jain |
| 7 | +@title: Design Patterns with Java 9 |
| 8 | +@link: https://premaseem.wordpress.com/category/computers/design-patterns/ |
| 9 | +*/ |
| 10 | +public class ClientStudent { |
| 11 | + public static void main (String[] args) { |
| 12 | + System.out.println(); |
| 13 | + System.out.println("University Lecture application designed using Visitor design pattern \n"); |
| 14 | + System.out.println("Subject available for lectures are:-"); |
| 15 | + System.out.println("Maths"); |
| 16 | + System.out.println("Computers"); |
| 17 | + System.out.println("Aviation"); |
| 18 | + System.out.println(); |
| 19 | + System.out.println("Please pick subject ..."); |
| 20 | + |
| 21 | + Scanner scanner = new Scanner(System.in); |
| 22 | + String subjectOption = scanner.next(); |
| 23 | + if (subjectOption.equalsIgnoreCase("Maths")){ |
| 24 | + System.out.println("Math can be taught by in house Faculty"); |
| 25 | + Subject subject = new Maths(); |
| 26 | + subject.teach(); |
| 27 | + } |
| 28 | + |
| 29 | + if (subjectOption.equalsIgnoreCase("Computers")){ |
| 30 | + System.out.println("Computers needs visiting Faculty, lets call Prof. Prem Aseem Jain :-)"); |
| 31 | + Subject subject = new Computer(); |
| 32 | + VisitingFaculty profAseem = new ProfAseem(); |
| 33 | + subject.acceptVisitingFacultytoTeach(profAseem); |
| 34 | + } |
| 35 | + |
| 36 | + if (subjectOption.equalsIgnoreCase("Aviation")){ |
| 37 | + System.out.println("Aviation needs visiting Faculty, lets call Prof. Prem Aseem Jain :-)"); |
| 38 | + Subject subject = new Aviation(); |
| 39 | + VisitingFaculty profAseem = new ProfAseem(); |
| 40 | + subject.acceptVisitingFacultytoTeach(profAseem); |
| 41 | + } |
| 42 | + |
| 43 | + System.out.println("Class over - Go Home and have fun :-) "); |
| 44 | + |
| 45 | + } |
| 46 | +} |
0 commit comments