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

namespace _230104
{
    class Program
    {
        static void Main(string[] args)
        {
            App app = new App();
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _230104
{
    class App
    {
        //생성자
        public App()
        {
            Reaver reaver = new Reaver();

            //상태 출력
            Console.WriteLine("유닛 이름 : {0}\n", reaver.name);
            Console.WriteLine("생명력 {0}/{1}", reaver.maxHp, reaver.hp);
            Console.WriteLine("실드 {0}/{1}", reaver.maxShield, reaver.shield);
            Console.WriteLine("이동속도 : {0}", reaver.moveSpeed);
            Console.WriteLine("공격력 : {0}\n", reaver.Dmg);

            //기능 출력
            reaver.Move();
            reaver.Att();
            reaver.ManufacturesScarab();
            reaver.Att();
            reaver.ManufacturesScarab();
            reaver.ManufacturesScarab();
            reaver.ManufacturesScarab();
            reaver.ManufacturesScarab();
            reaver.ManufacturesScarab();
            reaver.ManufacturesScarab();
            reaver.ManufacturesScarab();
            reaver.Att();
        }

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

namespace _230104
{
    class Reaver
    {
        public string name = "리버";
        public int maxHp = 100;
        public int hp = 100;
        public int maxShield = 80;
        public int shield = 80;
        public int Dmg = 100;
        public float moveSpeed = 0.833f;
        Scarab scarab = new Scarab();
        //생성자
        public Reaver()
        {
            
        }

        public void Move()
        {
            Console.WriteLine("{0}의 속도로 이동하였습니다.", this.moveSpeed);
        }

        public void ManufacturesScarab()
        {
            scarab.ScrabSum();
        }

        public void Att()
        {
            scarab.Att();
        }

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

namespace _230104
{
    class Scarab
    {
        private int Dmg = 100;
        private const int MAX = 6;
        public int total;       
        
        //생성자
        public Scarab()
        {

        }

        public void ScrabSum()
        {
            if(this.total < MAX)
            {
                total++;
                Console.WriteLine("스캐럽을 생산하였습니다. ({0}/{1})", this.total, MAX);
            }
            else
            {
                Console.WriteLine("스캐럽이 가득 찼습니다.");
            }            
        }

        public void Att()
        {
            if(total > 0)
            {
                total--;
                Console.WriteLine("공격({0})하였습니다.({1}/{2})", this.Dmg, this.total, MAX);
            }
            else
            {
                Console.WriteLine("스캐럽이 부족하여 공격할 수 없습니다.");
            }
        }
    }
}

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

클래스/메서드 과제2  (0) 2023.01.05
클래스/메서드 과제1  (0) 2023.01.05
클래스 과제4  (0) 2023.01.04
클래스 과제3  (0) 2023.01.04
클래스 과제2  (0) 2023.01.04

+ Recent posts