Exemple #1
0
        static void Main(string[] args)
        {
            DateTime birthdate = new DateTime(1975, 8, 18);
            Person   thePerson = new Person("Ravi", "Tambade", birthdate);

            Console.WriteLine(thePerson);

            DateTime birthdate2 = new DateTime(1995, 5, 23);
            Employee emp        = new Employee("Akash", "Bodhale", birthdate2, 23, "R&D", 12000, 25);
            float    salary     = emp.CalculateSalary();

            Console.WriteLine(" Akash Salary = {0}", salary);


            DateTime birthdate3 = new DateTime(1995, 5, 23);
            Employee emp2       = new SalesEmployee("Vibhuti", "Trivedi", birthdate2, 25, "Projects", 13100, 28, 5000);
            float    salary2    = emp2.CalculateSalary();

            Console.WriteLine(" Vibhuti Salary = {0}", salary2);


            //Person prn = thePerson;  //instace of person

            //Person prn = emp;
            Person prn = emp2;

            //Polymorphism for Tostring will be worked....

            Console.WriteLine("Polymorphic Behaviour");
            Console.WriteLine(prn);
            Console.ReadLine();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            SalesEmployee salesEmployee1 = new SalesEmployee()
            {
                Id           = 1,
                Base         = 1000,
                WorkingHours = 100,
                ExtraHours   = 5,
                Name         = "John",
                Family       = "Doe",
                NationalCode = "1234567890",
                TotalSales   = 10000000,
                Percentage   = 0.02
            };
            Teacher teacher1 = new Teacher()
            {
                Id           = 2,
                Name         = "Sarah",
                Family       = "Smith",
                Base         = 2000,
                WorkingHours = 50,
                NationalCode = "9876543210",
                Experience   = 3,
                Courses      = new string[] { "Java", "PHP", "MySQL" }
            };
            Student student1 = new Student()
            {
                Id           = 3,
                Name         = "David",
                Family       = "Doe",
                Course       = new string[] { "PHP", "MySQL" },
                EntranceYear = 1396,
                NationalCode = "8521479630"
            };
            Employee employee1 = new Employee()
            {
                Id           = 4,
                Name         = "Payam",
                Family       = "Payami",
                Base         = 3000,
                WorkingHours = 120,
                ExtraHours   = 10,
                NationalCode = "4568527419"
            };

            Person[] people = new Person[]
            {
                employee1, teacher1, student1, salesEmployee1
            };

            foreach (Person person in people)
            {
                Console.WriteLine(person);
            }

            Console.ReadKey();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Person.Institute = "Kahkeshan";
            SalesEmployee salesEmployee1 = new SalesEmployee()
            {
                Id           = 1,
                Base         = 1000,
                WorkingHours = 100,
                ExtraHours   = 5,
                Name         = "John",
                Family       = "Doe",
                NationalCode = "1234567890",
                TotalSales   = 10000000,
                Percentage   = 0.02
            };
            ////Person p = new Person()
            ////{
            ////    Name = "Ross",
            ////    Family = "Geller",
            ////    NationalCode = "4569871235",
            ////    Id = 5
            ////};
            Teacher teacher1 = new Teacher()
            {
                Id           = 2,
                Name         = "Sarah",
                Family       = "Smith",
                Base         = 2000,
                WorkingHours = 50,
                NationalCode = "9876543210",
                Experience   = 3,
                Courses      = new string[] { "Java", "PHP", "MySQL" }
            };
            Student student1 = new Student()
            {
                Id           = 3,
                Name         = "David",
                Family       = "Doe",
                Courses      = new string[] { "PHP", "MySQL" },
                EntranceYear = 1396,
                NationalCode = "8521479630"
            };
            Employee employee1 = new Employee()
            {
                Id           = 4,
                Name         = "Payam",
                Family       = "Payami",
                Base         = 3000,
                WorkingHours = 120,
                ExtraHours   = 10,
                NationalCode = "4568527419"
            };

            Person[] people = new Person[]
            {
                employee1, teacher1, student1, salesEmployee1
            };
            var balance = 0.0;

            Console.WriteLine($"{Person.Institute} Member List");
            foreach (Person person in people)
            {
                //if(person is SalesEmployee)
                //    Console.WriteLine(((SalesEmployee)person).GetTotalPaymentAmount());
                //else
                Console.WriteLine($"{person.ToString()}\t|{person.GetBalance():#,###}");
                balance += person.GetBalance();
            }
            Console.WriteLine("-------------------------------------------------------------------------------------------");
            Console.WriteLine($"\t\t\t\t\t\t\t\t\t\t|{balance:#,###}");
            //Console.WriteLine();
            //Math m = new Math();
            Console.ReadKey();
        }