Inheritance oj 3453 c # simple class

Title Description

Write code implements: defines three classes Bird, Mapie, Eagle. Wherein Bird is an abstract class, an abstract method defines Eat (). Mapie classes and class Bird Eagle derived class. Mapie class overrides the Eat. () Method, a heavy load Eat (int time) method. Eagle class also rewrite Eat. () Method.

Entry

Time value of the input parameter

Export

The name of each method

using System;
using System.IO;
using System.Globalization;
using System.Security.Cryptography;
using System.Text;

namespace myApp
{
    class Program
    {
        abstract class Bird
        {
            public abstract void Eat();
        }
        class Mapie : Bird
        {
            public override void Eat()
            {
                Console.WriteLine("Mapie eat!");
            }
            public int Eat(int time)
            {
                
                return time;
            }
        }
        class Eagle : Bird
        {
            public override void Eat()
            {
                Console.WriteLine("Eagle eat!");
            }
        }

        static void Main(string[] args)
        {
            int time;
            time = int.Parse(Console.ReadLine());
            Mapie m = new Mapie();
            m.Eat();
            Console.WriteLine("Mapie eat {0}!", time);
            Eagle e = new Eagle();
            e.Eat();
            e.Eat();
        }

    }

}
Published 24 original articles · won praise 28 · views 2263

Guess you like

Origin blog.csdn.net/weixin_46292455/article/details/104975064
Recommended