C#

클래스 연습5

s0002 2023. 1. 4. 23:18

using System;
using System.Collections.Generic;
using System.Text;

namespace Study03
{
    class App
    {
        public App()
        {
            Mushroom mushroom = new Mushroom();

            mushroom.Move();
            mushroom.Attack();
            mushroom.Hit();
            mushroom.Die();
        }   
    }
}
using System;
using System.Collections.Generic;
using System.Text;

namespace Study03
{
    class Mushroom
    {
        //멤버변수
        int level = 10;
        int hp = 125;
        int mp = 10;
        int exp = 17;

        //생성자
        public Mushroom()
        {
            Console.WriteLine("주황버섯이 생성되었습니다");
        }

        //멤버메서드
        public void Move()
        {
            Console.WriteLine("주황버섯이 이동합니다");
        }
        public void Attack()
        {
            Console.WriteLine("주황버섯이 공격합니다");
        }
        public void Hit()
        {
            Console.WriteLine("주황버섯이 공격당했습니다");
        }
        public void Die()
        {
            Console.WriteLine("주황버섯이 죽었습니다");
        }
    }
}

'C#' 카테고리의 다른 글

스타크래프트 시즈탱크 만들기  (0) 2023.01.05
스타크래프트 마린, 메딕 만들기  (0) 2023.01.05
클래스 연습4  (0) 2023.01.04
클래스 연습3  (0) 2023.01.04
클래스 연습2  (0) 2023.01.04