c#/수업 과제

버스트

yeeendy 2023. 1. 6. 05:45

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

namespace study03
{
    internal class Burst
    {
        int drift;
        int accelerationForce;
        public int boost;
        public int maxBoost;
        //생성자
        public Burst()
        {

        }
        public void UseBoost()
        {
            if (this.boost > 0) 
            {
                this.boost = this.maxBoost;
                this.boost = this.boost - 1;
                Console.WriteLine("부스트를 {0}번 사용했습니다. ({0}/{1})", this.boost, this.maxBoost);
            }
            else
            {
                Console.WriteLine("부스트가 없습니다.");
            }
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace study03
{
    internal class App
    {
        //생성자
        public App()
        {
            Burst burst = new Burst();
            burst.boost = 3;
            burst.maxBoost = 3;
            burst.UseBoost();
            burst.UseBoost();
            burst.UseBoost();
        }
    }
}

UseBoost를 호출 하면 횟수를 닳게 하고 싶은데 어디서 설정을 해야되는지 모르겠다.

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

List<T> 를 이용한 인벤토리 만들기  (0) 2023.01.11
인벤토리 만들기2  (0) 2023.01.09
Naranjo  (0) 2023.01.05
Chimu  (0) 2023.01.05
질럿  (0) 2023.01.04