Пример #1
0
        static void Main(string[] args)
        {
            Nkandla Nkandla = new Nkandla();

            Politician Helen = new Politician("Helen Zille", PersonType.Politician)
            {
                politicalParty = "DA",
                age            = 67,
            };

            Politician Julius = new Politician("Julius Malema", PersonType.Politician)
            {
                politicalParty = "EFF",
                age            = 43,
            };

            Politician Cyril = new Politician("Cyril Ramphosa", PersonType.Politician)
            {
                politicalParty = "ANC",
                age            = 43,
            };

            Console.WriteLine(Nkandla.accept(Cyril));

            Console.ReadLine();
        }
Пример #2
0
        public string accept(IVisitor visitor)
        {
            Politician politician = visitor as Politician;

            if (politician.politicalParty != "ANC")
            {
                throw new InvalidOperationException("HAMBA WENA!");
            }
            else
            {
                visitor.visit(this);
                return($"Welcome to {this.name}, {politician.getName()}");
            }
        }
Пример #3
0
        public VisitorTests()
        {
            Helen = new Politician("Helen Zille", PersonType.Politician)
            {
                age            = 57,
                gender         = 'F',
                politicalParty = "DA"
            };

            Julius = new Politician("Julius Malema", PersonType.Politician)
            {
                age            = 43,
                gender         = 'M',
                politicalParty = "EFF"
            };

            Cyril = new Politician("Cyril Ramaphosa", PersonType.Politician)
            {
                age            = 197,
                gender         = 'M',
                politicalParty = "ANC"
            };
        }