c#/수업 과제

코크버섯

yeeendy 2023. 1. 4. 22:35

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

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

        }
        
        public void Attack()
        {
            Console.WriteLine("코크버섯이 공격했습니다.");
        }
        public void GiveMeso()
        {
            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() 
        {
            CokeMushroom cokeMushroom = new CokeMushroom();

            cokeMushroom.hp = 375;
            cokeMushroom.exp = 35;
            
            Console.WriteLine("체력: {0}", cokeMushroom.hp);
            Console.WriteLine("경험치: {0}", cokeMushroom.exp);

            cokeMushroom.Attack();
            cokeMushroom.GiveMeso();

        }

    }
}

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
주황버섯  (0) 2023.01.04
메서드 연습4  (0) 2023.01.03