コード例 #1
0
 private void PriceBtn_Click(object sender, EventArgs e)
 {
     if (rdClient.Checked == true)
     {
         Client c1 = new Client(tbBirthday.Text);
         tbPrice.Text = Convert.ToString(c1.priceCalculation());
     }
     if (rdStudent.Checked == true)
     {
         Student s1 = new Student(tbBirthday.Text, comboBox1.Text);
         tbPrice.Text = Convert.ToString(s1.priceCalculation());
     }
     if (rdPens.Checked == true)
     {
         Pensioner p1 = new Pensioner(tbBirthday.Text, comboBox2.Text);
         tbPrice.Text = Convert.ToString(p1.priceCalculation());
     }
 }
コード例 #2
0
        public static void TestVisitor()
        {
            Console.WriteLine("----------------------Visitor----------------------");
            Visitor.Client child     = new Child("John");
            Visitor.Client adult     = new Adult("Marry");
            Visitor.Client pensioner = new Pensioner("Richard");

            IInsurer ergo = new ErgoInsurance();
            IInsurer lietuvosDraudimas = new LietuvosInsurance();

            child.GetInsuranceCost(ergo);
            child.GetInsuranceCost(lietuvosDraudimas);
            adult.GetInsuranceCost(ergo);
            adult.GetInsuranceCost(lietuvosDraudimas);
            pensioner.GetInsuranceCost(ergo);
            pensioner.GetInsuranceCost(lietuvosDraudimas);

            Console.WriteLine("---------------------------------------------------\n");
        }
コード例 #3
0
        static void Main(string[] args)
        {
            CitizenCollection persons = new CitizenCollection();

            Pensioner pensioner = new Pensioner("p3", "p3");

            persons.Add(new Student("s1", "s1"));
            persons.Add(new Worker("w1", "w1"));
            persons.Add(new Pensioner("p1", "p1"));
            LogPersons(persons);
            persons.Add(new Student("s2", "s2"));
            persons.Add(new Worker("w2", "w2"));
            persons.Add(new Pensioner("p2", "p2"));
            LogPersons(persons);
            persons.Add(new Pensioner("p2", "p2"));
            persons.Add(pensioner);
            LogPersons(persons);
            persons.Remove();
            LogPersons(persons);
            persons.Remove(pensioner);
            LogPersons(persons);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            Student   student1    = new Student(1, "Studen1Name", "Student2Surname");
            Student   studentCopy = new Student(1, "Studen1Name", "Student2Surname");
            Pensioner pensioner1  = new Pensioner(2, "Pensioner1Name", "Pensioner1Surname");
            Worker    worker1     = new Worker(3, "Worker1Name", "Worker2Surname");
            Pensioner pensioner2  = new Pensioner(4, "Pensioner2Name", "Pensioner2Surname");

            CitizenCollection collection = new CitizenCollection();

            collection.Add(student1);
            //collection.Add(studentCopy);
            collection.Add(pensioner1);
            collection.Add(worker1);
            collection.Add(pensioner2);

            foreach (Citizen item in collection)
            {
                System.Console.WriteLine($"{item.Id} {item.Name}");
            }

            System.Console.WriteLine();

            collection.Remove(pensioner1);

            foreach (Citizen item in collection)
            {
                System.Console.WriteLine($"{item.Id} {item.Name}");
            }

            System.Console.WriteLine();

            collection.Remove(worker1);
            foreach (Citizen item in collection)
            {
                System.Console.WriteLine($"{item.Id} {item.Name}");
            }
        }