Beispiel #1
0
        public VetoEventArgs Vote(string proposal)
        {
            VetoEventArgs veto = new VetoEventArgs(proposal);

            OnVote?.Invoke(this, veto);
            return(veto);
        }
Beispiel #2
0
        public void Veto(object sender, VetoEventArgs e)
        {
            Random rand = new Random();

            if (e.VetoBy == null && rand.Next(5) == 0)
            {
                e.VetoBy = this;
            }
        }
Beispiel #3
0
        static void Main()
        {
            VetoComission comission = new VetoComission();

            VetoVoter[] voters = new VetoVoter[5];
            for (int i = 0; i < voters.Length; i++)
            {
                voters[i]         = new VetoVoter($"Voter{i + 1}");
                comission.OnVote += voters[i].Veto;
            }
            VetoEventArgs veto = comission.Vote(Console.ReadLine());

            if (veto.VetoBy != null)
            {
                Console.WriteLine($"Vetoed by {veto.VetoBy}");
            }
            else
            {
                Console.WriteLine("Not vetoed");
            }
        }