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

            ////use get/set to interact w object's name
            //emp.Name="Marv";//can't use () like a method, needs this syntax
            //Console.WriteLine("Employee is named: {0}", emp.Name);

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

            //Employee joe = new Employee();
            //joe.Age++;

            Employee lucas = new Employee("Lucas", 32,234, 45000, 368925583.ToString());
            lucas.DisplayStats();

            Console.ReadLine();

            ////Error! can't access private object members!
            //emp.empName = "Marv";
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Employee emp = new Employee("Marv", 23, 0, 20000, "321-abc");

            // Give the employee a bonus
            emp.GiveBonus(1000);
            emp.DisplayStats();

            Console.ReadLine();
        }
Beispiel #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();
            emp.Name = "Marv";
            Console.WriteLine("Employee is named: {0}", emp.GetName());
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Encapsulation *****\n");
            Console.WriteLine("These folks work at {0}.", Employee.Company);

            Employee emp = new Employee("Marvin", 24, 456, 30000, "111-11-1111");

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

            Console.ReadLine();
        }
Beispiel #5
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();
        }
Beispiel #6
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();
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun whith Encapsulation *****\n");
            Employee emp = new Employee("Marvin", 456, 30000);

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

            // Установка и получение свойства Name.

            Console.WriteLine("Employee is named: {0}", emp.Name);
            Console.ReadLine();
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            Console.WriteLine("***Encapsulation***");
            Employee emp = new Employee("Marvin", 18, 456, 30000, "322322");
            Employee joe = new Employee();

            joe.Age++;
            emp.GiveBonus(1000);
            emp.DisplayStats();

            emp.Name = "Marv";
            Console.WriteLine("Emp is named: {0}", emp.Name);
            Console.ReadLine();
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Encapsulation *****\n");
            Employee emp = new Employee("Marvin", 456, 30000);

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

            // Reset and then get the Name property.
            emp.Name = "Marv";
            Console.WriteLine("Employee is named: {0}", emp.Name);
            emp.Age++;
            Console.ReadLine();
        }
Beispiel #10
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();
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            Console.WriteLine("**** Fun With Encapsulation*****\n");
            Employee Marvin = new Employee("Marvin", 256, 30000);

            Marvin.DisplayStats();
            Marvin.Name = "Marv";
            Console.WriteLine("Employee is namde {0}*\n", Marvin.Name);

            Employee joe = new Employee("Joe", 2, 2, 2, "");

            Console.WriteLine("Employee is namde {0}*", joe.Name);
            joe.DisplayStats();
            joe.Age++;
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Encapsulation ***** \n");
            Employee emp = new Employee("Marvin", 456, 3000);
            emp.GiveBonus(1000);
            emp.DisplayStats();

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

            Employee joe = new Employee();
            joe.Age++;
            Console.WriteLine("Joe's age is {0}", joe.Age);

            Console.ReadKey();
        }
Beispiel #13
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();
        }
Beispiel #14
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++;
        }
Beispiel #15
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Employee App *****\n");
            Employee employee1 = new Employee("Marvin", 456, 30000);

            employee1.GiveBonus(1000);
            employee1.DisplayStats();
            Console.WriteLine("Employee ID : " + employee1.ID);

            Employee employee2 = new Employee("Karth", 25, 22, 40000);

            employee2.DisplayStats();

            // Set and get the Name property.
            employee1.Name = "Okashi";
            Console.WriteLine("Employee1 is now named: {0}", employee1.Name);
            Console.ReadLine();
        }
Beispiel #16
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.Name = ("Marv");
            Console.WriteLine("Employee is named: {0}", emp.Name);
            Console.WriteLine();

            Employee emp2 = new Employee();

            emp2.Name = ("Xena the warrior princess");

            Console.ReadLine();
        }
Beispiel #17
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();
        }
Beispiel #18
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();
        }
Beispiel #19
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Encapsulation *****\n");
            Employee emp = new Employee("Marvin", 4569, 30000);

            emp.Age++;
            emp.GiveBonus(1000);
            emp.DisplayStats();
            Console.WriteLine(emp.SocialSecurityNumber);

            /*
             * //Использовать методы get/set для взаимодействия с именем объекта
             * emp.SetName("Marv");
             * Console.WriteLine("Employee is named: {0}", emp.GetName());
             */
            // Установка и получение свойства Name
            emp.Name = "Marv";
            Console.WriteLine("Employee is named: {0}", emp.Name);
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Encapsulation *****");

            Employee emp = new Employee("Marvin", 456, 30000);

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

            //Using get/set properties
            emp.Name = "Marv";
            Console.WriteLine($"Employee is named: {emp.Name}");

            Employee emp2 = new Employee();

            emp2.Name = "Xena the warrior princess";
            Console.WriteLine($"Employee is named: {emp2.Name}");

            Console.ReadLine();
        }
Beispiel #21
0
        static void Main(string[] args)
        {
            Employee emp = new Employee();

            emp.Name = "Gregory";
            emp.DisplayStats();
            Console.WriteLine();
            Employee empy = new Employee("Marvin", 456, 30000);

            empy.GiveBonus(1000);
            empy.DisplayStats();
            empy.Name = "Marv";
            Console.WriteLine("After we changed the employees name it became: {0}", empy.Name);
            Employee xena = new Employee();

            // This will throw an error
            // since it's longer than 15
            // characters.
            xena.Name = "XENA THE WARRIOR PRINCESS";
            Console.ReadLine();
        }
        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();
        }
Beispiel #23
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Encapsulation *****\n");
            Console.WriteLine("These folks work at {0}", Employee.Company);

            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.Name = "Marv";
            Console.WriteLine("Employee is named: {0}", emp.Name);

            Employee emp2 = new Employee();

            // Longer than 15 characters!  Error will print to console.
            emp2.Name = "Xena the warrior princess";

            Console.ReadLine();
        }
Beispiel #24
0
        static void Main(string[] args)
        {
            ////Employee emp = new Employee();
            ////// 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");
            //// Replaced getter and setters with properties:

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

            //Console.ReadLine();

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


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

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