/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Assignment;

class BridgePatternTest {
     
     public static void main(String []arg){
        ConcreteRemotePM conRemot=new ConcreteRemotePM("Sony Remote ");

        conRemot.implementor=new Sony();
        conRemot.implementor=new Philips();
        conRemot.nextChannel();
        conRemot.prevChannel();
        
        conRemot.setChannel(0);
     }
}


interface TV{
        public void on();
        public void off();
        public void tuneChannel(int channel);
    }
    

   class Sony implements TV{
    public void on() {
        System.out.println("Sony TV turned On. ");
    }

    public void off() {
        System.out.println("Sony TV turned Off. ");
    }

    public void tuneChannel(int channel) {
       System.out.println("Tunning sony TV. ");
    }       
 }
   
   
  class Philips implements TV{
    public void on() {
        System.out.println("Philips TV turned On. ");
    }

    public void off() {
        System.out.println("Philips TV turned Off. ");
    }

    public void tuneChannel(int channel) {
       System.out.println("Philips TV tunned. ");
    }       
 }  
  
  
  
 abstract class RemoteControl{
     protected TV implementor;
     public void on(){
         implementor.off();
     }
     public void off(){
         implementor.off();
     }
     public void setChannel(int channel){
         implementor.tuneChannel(channel);
     }
 }  
//Refine Abstraction 
 class ConcreteRemotePM extends RemoteControl{
     private int currentChannel;
     private String remoteType;
     
     public ConcreteRemotePM(String rt){
         remoteType=rt;
     }
     public void nextChannel(){
         currentChannel++;
         setChannel(currentChannel);
         System.out.println("Channel set to: "+currentChannel);
     }
     public void prevChannel(){
         currentChannel--;
         setChannel(currentChannel);
         System.out.println("Channel set to: "+currentChannel);
     }
 }
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   