Esempio n. 1
0
        static void Main(string[] args)
        {
            Apple apple  = new Apple("Красное яблоко", 50, 100);
            Apple apple2 = new Apple("зеленое яблоко", 40, 300);

            var SummApple    = Apple.Add(apple, apple2);
            var SUmmApple2   = apple + apple2;
            var SummAppleInt = apple + 600;

            Console.WriteLine(apple);
            Console.WriteLine(apple2);
            Console.WriteLine(SummApple);
            Console.WriteLine(SUmmApple2);
            Console.WriteLine(SummAppleInt);
            Console.ReadLine();
        }
Esempio n. 2
0
        static public Apple Add(Apple apple1, int volume)
        {
            var apple = new Apple(apple1.Name, apple1.Calorie, volume + apple1.Volume);

            return(apple);
        }
Esempio n. 3
0
 public static Apple operator +(Apple apple1, int volume)
 {
     return(Apple.Add(apple1, volume));
 }
Esempio n. 4
0
 public static Apple operator +(Apple apple1, Apple apple2)
 {
     return(Apple.Add(apple1, apple2));
 }