예제 #1
0
파일: Tovar.cs 프로젝트: Allemel/123
        public string IAmPrinting(IAlla obj)
        {
            Tovar      isTovar      = obj as Tovar;
            Technika   isTechnika   = obj as Technika;
            Pechatalki isPechatalki = obj as Pechatalki;
            Scaner     isScaner     = obj as Scaner;
            Komp       isKomp       = obj as Komp;
            Planshet   isPlanshet   = obj as Planshet;

            if (isTovar != null)
            {
                return(isTovar.ToString());
            }
            if (isTechnika != null)
            {
                return(isTechnika.ToString());
            }
            if (isPechatalki != null)
            {
                return(isPechatalki.ToString());
            }
            if (isScaner != null)
            {
                return(isScaner.ToString());
            }
            if (isKomp != null)
            {
                return(isKomp.ToString());
            }
            if (isPlanshet != null)
            {
                return(isPlanshet.ToString());
            }
            return("");
        }
예제 #2
0
파일: Program.cs 프로젝트: Allemel/123
        static void Main(string[] args)
        {
            Tovar  tov     = new Tovar();
            Scaner scan    = new Scaner();
            Komp   kompich = new Komp();
            IAlla  scaner  = new Scaner();
            IAlla  tovar   = new Tovar();
            IAlla  kom     = new Komp();
            var    fds     = scaner as Scaner;

            if (fds != null)
            {
                Console.WriteLine(fds.Dod());
            }
            Printer pri = new Printer();

            IAlla[] allmass = new IAlla[3];
            allmass[0] = scaner;
            allmass[1] = tovar;
            allmass[2] = kom;
            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine(pri.IAmPrinting(allmass[i]));
            }
        }