Menu



Manage

Study_C# > 9/Animal.cs Lines 40 | 916 바이트
다운로드

                        using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

///Base 클래스(기반 클래스) -> 부모 대신 베이스라는 말을 씀
/// C++은 다중 상속이 되고, C#,JAVA는 단일상속이라 부모,베이스 라고 함

namespace week10
{
    internal abstract class Animal
    {
        private String Name;
        public string name
        {
            get { return this.Name; }
            set { this.Name = value; }
        }
        private int Age;
        public int age
        {
            get { return this.Age; }
            set { this.Age = value; }
        }

        public Animal(string name, int age) {
            Name = name;
            Age = age;
        }

        public void AddAge()
        {
            this.Age++;
        }

        public abstract void sleep();
    }
}