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를 호출 하면 횟수를 닳게 하고 싶은데 어디서 설정을 해야되는지 모르겠다.