Esempio n. 1
0
        static void Main(string[] args)
        {
            Rectagle recA = new Rectagle(10, 6);

            recA.CalculatePerimeter();
            Rectagle recB = new Rectagle();

            recB = recA * 9;
            recB.CalculatePerimeter();
            Console.WriteLine(recB.ToString());
            if (recA > recB)
            {
                Console.WriteLine("recA > recB");
            }
            else
            {
                Console.WriteLine("recA < recB");
            }
            recA.WriteToFile();
            Console.WriteLine(recA.GetHashCode());
            if (recA.Equals(recB))
            {
                Console.WriteLine("recA == recB");
            }
            else
            {
                Console.WriteLine("recA != recB");
            }

            Console.WriteLine("recB as Figure = {0}", recB as Figure);
            Console.WriteLine("recB as ICloneable = {0}", recB as ICloneable);
            Console.WriteLine("recB is Figure = {0}", recB is Figure);
            Console.WriteLine("recB as ICloneable = {0}", recB is ICloneable);
        }
Esempio n. 2
0
        public static Rectagle operator *(Rectagle recA, int num)
        {
            Rectagle res = new Rectagle();

            res.A = recA.A * num;
            res.B = recA.B * num;
            return(res);
        }
Esempio n. 3
0
        public static Rectagle operator +(Rectagle recA, Rectagle recB)
        {
            Rectagle res = new Rectagle();

            res.A = recA.A + recB.A;
            res.B = recA.B + recA.B;
            return(res);
        }