예제 #1
0
        static void Main(string[] args)
        {
            // Error! Cannot directly access private members
            // from an object!
            //emp.empName = "Marv";

            Console.WriteLine("***** Fun with Encapsulation *****\n");
            Employee emp = new Employee("Marvin", 456, 30000);

            emp.GiveBonus(1000);
            emp.DisplayStats();
            // Use the get/set methods to interact with the object's name.
            emp.SetName("Marv");
            Console.WriteLine("Employee is named: {0}", emp.GetName());

            // Longer than 15 characters! Error will print to console.
            Employee emp2 = new Employee();

            emp2.SetName("Xena the warrior princess");

            // Reset and then get the Name property.
            emp.Name = "Marv";
            Console.WriteLine("Employee is named: {0}", emp.Name);


            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Encapsulation *****\n");
            Employee emp = new Employee("Marvin", 456, 30000);

            emp.GiveBonus(1000);
            emp.DisplayStats();
            emp.Name = "Marv";
            Console.WriteLine("Employee is named: {0}", emp.GetName());
            Console.ReadLine();
        }
예제 #3
0
파일: Program.cs 프로젝트: h3n7vi/laba2
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Encapsulation***\n");
            Employee emp = new Employee("Marvin", 456, 30000);

            emp.GiveBonus(1000);
            emp.DisplayStats();
            // Использовать методы get/set для взаимодействия с именем обьекта
            emp.SetName("Marv");
            Console.WriteLine("Employee is named: {0}", emp.GetName());
            Console.ReadLine();
        }
예제 #4
0
        static void Main(string[] args)
        {
            Employee emp = new Employee("Marvin", 456, 30000);

            emp.GiveBonus(1000);
            emp.DisplayStats();

            // Use the get/set methods to interact with the object's name.
            emp.SetName("Marv");
            Console.WriteLine("Employee is named: {0}",
                              emp.GetName());
            Console.ReadLine();
        }
예제 #5
0
        static void Main(string[] args)
        {
            //Теперь все в порядке;
            Console.WriteLine("***** Fun with Encapsulation *****\n");
            Employee emp = new Employee("Marvin", 456, 30000);

            emp.GiveBonus(1000);
            emp.DisplayStatus();

            //Использование get/set для взаимодействия с именами объектов;
            emp.SetName("Marv");
            Console.WriteLine("Employee is named: {0}", emp.GetName());
            Console.ReadKey();
        }
예제 #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("**** Fun with Encapsulation ****\n");
            Employee emp = new Employee("Marvin", 456, 30000);

            emp.GiveBonus(1000);
            emp.DisplayStats();

            // Использовать методы get/set ждя взаимодействия с именем обьекта.
            emp.SetName("Marv");
            Console.WriteLine("Employee is named: {0} ", emp.GetName());
            Console.ReadLine();

            // Создаем joe
            Employee joe = new Employee();

            joe.Age++; // Упращенние записи "joe.setAge(joe.GetAge() + 1;"
            Console.ReadLine();
        }
예제 #7
0
        private static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Encapsulation ****\n");
            var emp = new Employee("Marvin", 456, 30000, 20);

            emp.GiveBonus(1000);
            emp.DisplayStats();

            emp.Name = "Marv";
            Console.WriteLine("Employee is named: {0}", emp.GetName());

            var emp2 = new Employee();

            emp2.SetName("Xena the warrior princess");

            var joe = new Employee();

            joe.Age++;

            Console.ReadLine();
        }
예제 #8
0
        static void Main(string[] args)
        {
            Console.WriteLine("*** Fun with Encapsulation ***");
            Employee emp = new Employee("Jake", 30, 30000);

            emp.GiveBonus(1000);
            emp.Display();

            emp.SetName("Mike");
            Console.WriteLine("Employee is named: {0}", emp.GetName());

            Employee emp2 = new Employee();

            emp2.Name = "Xena";
            Console.WriteLine("Name of Employee: {0}", emp2.Name);

            Employee joe = new Employee();

            joe.Age++;
            joe.Display();

            Console.ReadLine();
        }