コード例 #1
0
        public string accept(Visitor person)
        {
            string returnStr;

            if (person is Politician)
            {
                Politician pol = (Politician)person;

                if (pol.getParty() == "ANC")
                {
                    return(pol.visit(this));
                }
                else
                {
                    throw new VisitorNotAllowedException("Visit method could not be called, because this visitor may not enter " + name);
                }
            }
            else
            {
                throw new VisitorNotAllowedException("Visit method could not be called, because this person is not a visitor");
            }
        }