Beispiel #1
0
        public VetoEventArgs Vote(string Proposal)
        {
            VetoEventArgs vetoVoteArgs = new VetoEventArgs(Proposal);

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

            if (e.VetoBy != null)
            {
                return;
            }
            if (r.Next(0, 5) == 1)
            {
                e.VetoBy = this;
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            VetoComission vetoC = new VetoComission();

            VetoVoter[] voters     = new VetoVoter[5];
            string[]    voterNames = { "maria", "marina", "mariana", "masha", "marusia" };

            for (int i = 0; i < voters.Length; i++)
            {
                voters[i]     = new VetoVoter(voterNames[i]);
                vetoC.OnVote += voters[i].VetoVote;
            }

            VetoEventArgs voteResults = vetoC.Vote("убрать дистант");

            Console.WriteLine($"proposal: {voteResults.Proposal}. vote result: {(voteResults.VetoBy == null ? "approved" : "vetoed")}.");
            if (voteResults.VetoBy != null)
            {
                Console.WriteLine($"vetoed by: {voteResults.VetoBy.Name}.");
            }
        }