c#/수업 과제

뿔버섯

yeeendy 2023. 1. 4. 22:31

 

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

namespace study02
{
    internal class HornyMushroom
    {
        public int hp;
        public int exp;
        //생성자
        public HornyMushroom()
        {

        }
        
        public void Attack()
        {
            Console.WriteLine("뿔버섯이 공격했습니다.");
        }
        public void GiveItem()
        {
            Console.WriteLine("아이템을 주었습니다.");
        }

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

namespace study02
{
    internal class App
    {
        //생성자
        public App() 
        {
            HornyMushroom hornyMushroom = new HornyMushroom();

            hornyMushroom.hp = 175;
            hornyMushroom.exp = 21;
            
            Console.WriteLine("체력: {0}", hornyMushroom.hp);
            Console.WriteLine("경험치: {0}", hornyMushroom.exp);

            hornyMushroom.Attack();
            hornyMushroom.GiveItem();

        }

    }
}

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

namespace study02
{
    internal class Program
    {
        static void Main(string[] args)
        {
            new App();
        }
    }
}

'c# > 수업 과제' 카테고리의 다른 글

골리앗  (0) 2023.01.04
코크버섯  (0) 2023.01.04
주황버섯  (0) 2023.01.04
메서드 연습4  (0) 2023.01.03
메서드 연습3  (0) 2023.01.03