Esempio n. 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();
        }
Esempio n. 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.SetName("Marv");
            Console.WriteLine("Employee is named: {0}", emp.GetName());
            Console.ReadLine();
        }
Esempio n. 3
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();
        }
Esempio n. 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();
        }
Esempio n. 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();
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Console.WriteLine("**** Fun wiht Encapsulation ****\n");

            Employee emp = new Employee("Marvin", 456, 30000);
            emp.GiveBonus(1000);
            emp.DisplayStats();

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

            Employee emp2 = new Employee();
            emp2.SetName("Xena the wrairre princess");

            Console.ReadLine();
        }
Esempio n. 7
0
        static void Main( string[] args )
        {
            Console.WriteLine("***** Fun with Encapsulation *****\n");
            Employee emp = new Employee("Marvin", 456, 30000);
            emp.GiveBonus(1000);
            emp.DisplayStats();

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

            // Longer than 15 characters!  Error will print to console.
            Employee emp2 = new Employee();
            emp2.SetName("Xena the warrior princess");

            Console.ReadLine();
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            //Console.WriteLine("***** Fun with Encapsulation *****\n");
            //Employee emp = new Employee("Marvin", 456, 30000);
            //emp.GiveBonus(1000);
            //emp.DisplayStats();

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

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

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

            Console.ReadLine();
        }
Esempio n. 9
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Employee App .. ");
            Employee emp = new Employee("Marvin", 456, 30000);

            emp.GiveBonus(1000);
            emp.Name = "Marv";
            emp.DisplayStats();


            Employee emp2 = new Employee();

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

            Employee joe = new Employee();

            joe.Age++;
        }
Esempio n. 10
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();
        }
Esempio n. 11
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();
        }
Esempio n. 12
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();
        }