예제 #1
0
        //overload the + operator
        public static DancerPoints operator +(DancerPoints a, DancerPoints b)
        {
            string       n1  = a.name + " & " + b.name;
            int          p2  = a.points + b.points;
            DancerPoints res = new DancerPoints(n1, p2);

            return(res);
        }
예제 #2
0
        static void Main(string[] args)
        {
            string name1   = Console.ReadLine();
            int    points1 = Convert.ToInt32(Console.ReadLine());
            string name2   = Console.ReadLine();
            int    points2 = Convert.ToInt32(Console.ReadLine());

            DancerPoints dancer1 = new DancerPoints(name1, points1);
            DancerPoints dancer2 = new DancerPoints(name2, points2);

            DancerPoints total = dancer1 + dancer2;

            Console.WriteLine(total.name);
            Console.WriteLine(total.points);
        }