Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 
avatar of N.I.R.E.X

N.I.R.E.X

N.I.R.E.X has asked 1 questions and find answers to 3 problems.

Stats

38
EtPoint
3
Vote count
1
questions
3
answers

About

There is not much about me... My whole life is based on one snippet of code!

namespace MyLife
{
    private class Day
    {
        public Coffee myGlass = new Coffee();
        public Day()
        {
            myGlass.OnSip += myGlass_OnSip;
            myGlass.OnEnd += myGlass_OnEnd;
            while(true)
            {
                myGlass.sip();
            }
        }

        void myGlass_OnSip(object sender, CoffeeArgs e)
        {
            Me.Relax();
            Me.Sigh();
        }

        void myGlass_OnEnd(object sender, CoffeeArgs e)
        {
            myGlass.refill();
        }
    }

    public class Coffee
    {
        public delegate void drink(object sender, CoffeeArgs e);
        public event drink OnSip;
        public event drink OnEnd;

        public float amount;

        public void refill()
        {
            this.amount = 100;
        }

        public void sip()
        {
            if (amount > 0)
            {
                this.amount--;
                CoffeeArgs coffeeArgs = new CoffeeArgs(this.amount);
                OnSip(this, coffeeArgs);
            }
            else
            {
                CoffeeArgs coffeeArgs = new CoffeeArgs(this.amount);
                OnEnd(this, coffeeArgs);
            }
        }
    }
}