Esempio n. 1
0
File: Tovar.cs Progetto: Allemel/123
        public int CompareTo(object obj)
        {
            Tovar tov = obj as Tovar;

            if (tov == null)
            {
                throw new ArgumentException("Not tovarius!");
            }



            if (Price == tov.Price)
            {
                return(0);
            }
            if (Price > tov.Price)
            {
                return(1);
            }
            if (Price < tov.Price)
            {
                return(-1);
            }
            return(0);
        }
Esempio n. 2
0
File: Tovar.cs Progetto: 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("");
        }
Esempio n. 3
0
        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]));
            }
        }
Esempio n. 4
0
File: Tovar.cs Progetto: Allemel/123
 public bool Equals(Tovar tov)
 {
     if ((Price == tov.Price) && (Weight == tov.Weight) && (Nameki == tov.Nameki))
     {
         return(true);
     }
     return(false);
 }