반응형
using System;
using System.Collections.Generic;
using System.Text;

namespace 인터페이스2
{

    class Car
    {
        private string CarNo;

  
        public void Power() 
        {
            Console.WriteLine("흡입 압축 폭발 배기 ");
        }
        public void ABS() 
        {
            Console.WriteLine(" anti lock break system"); 
        }
        public void Misson()
        {
            Console.WriteLine( " 1단 2단 3단 4단 5단 6단 후진 중립" ); 

        }
        public void Turbo() 
        {
            Console.WriteLine("과흡기  --> ");
        }
    }

    interface IDriver
    {
        void On();
        void Off();
        void Go();
        void Stop();          
    }
    class Explor : Car , IDriver
    {


        public void On()
        {
            throw new NotImplementedException();
        }

        public void Off()
        {
            throw new NotImplementedException();
        }

        public void Go()
        {
            throw new NotImplementedException();
        }

        public void Stop()
        {
            throw new NotImplementedException();
        }
    }


    class spark :  Car , IDriver
    {

        public void On()
        {
            throw new NotImplementedException();
        }

        public void Off()
        {
            throw new NotImplementedException();
        }

        public void Go()
        {
            throw new NotImplementedException();
        }

        public void Stop()
        {
            throw new NotImplementedException();
        }
    }
   


    class BestDriver
    {
        public void Drive( Explor explor )
        {
            explor.On(); 

        }
    }
    class Student : BestDriver 
    { 
    
    }
    class teacher : BestDriver
    { 
    
    }


    class Program
    {
        static void Main(string[] args)
        {
            Explor explor =  new Explor();
          //  K_madam k = new K_madam();
            


            BestDriver[] bd = new BestDriver[2];
            bd[0] = new Student();
            bd[1] = new teacher();
            bd[0].Drive(explor); 
            foreach (BestDriver  b in bd)
            {
                b.Drive(idriver); 
            }
            
            
            //   idriver.
            // 인터페이스의 구현 및 사용 !! 
            // 1) 다중상속처럼 사용할수 있다 !! 
            // 2) 프로그램의 결합도를  낮춘다 !! 

        


        }
    }
}

'C#' 카테고리의 다른 글

[C#] 필드멤버  (0) 2014.11.18
[C#] 추상클래스  (0) 2014.11.18
[C#] 인덱서  (0) 2014.11.18
[C#] 이벤트  (0) 2014.11.18
[C#] 예외처리  (0) 2014.11.18

+ Recent posts