Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- interface FlightDetails {
- void getFlightDetails();
- void book(Ticket ticket);
- }
- class AirIndia implements FlightDetails {
- public void getFlightDetails() {
- System.out.println("Flight Details of Air India");
- }
- public void book(Ticket ticket) {
- System.out.println("Ticket booked in Air India");
- }
- }
- class Emirates implements FlightDetails {
- public void getFlightDetails() {
- System.out.println("Flight Details of Emirates");
- }
- public void book(Ticket ticket) {
- System.out.println("Ticket booked in Emirates");
- }
- }
- class Lufthansa implements FlightDetails {
- public void getFlightDetails() {
- System.out.println("Flight Details of Lufthansa");
- }
- public void book(Ticket ticket) {
- System.out.println("Ticket booked in Lufthansa");
- }
- }
- class Ticket{
- }
- public class InterfaceFlight {
- public static void main(String[] args) throws IOException {
- FlightDetails flight = null;
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- System.out.println("1.Air Indian2.Emiratesn3.Lufthansa");
- System.out.print("Enter choice = ");
- int choice = Integer.parseInt(br.readLine());
- if(choice == 1){
- flight = new AirIndia();
- flight.book(new Ticket());
- } else if(choice == 2){
- flight = new Emirates();
- flight.book(new Ticket());
- } else if(choice == 3){
- flight = new Lufthansa();
- flight.book(new Ticket());
- }
- }
- }
Add Comment
Please, Sign In to add comment