Exemple #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("*** Fun with Class Types ***\n");
                // Allocate and configure a Car object
                Car mycar = new Car();
                Car myCar2 = new Car("Cherry", 20000){ petName = "Henry", currSpeed = 10};

                // Speed up the car a few times and print out the new state
                for (int i = 0; i < 10; i++) {
                    mycar.Speedup(5);
                    mycar.PrintState();
                }

                // Weird method using optinal a
                myCar2.weirdMethod();
                myCar2.weirdMethod(10,10);
                myCar2.weirdMethod(x: 10);
                myCar2.weirdMethod(y: 4);

            Console.WriteLine("**** Employee class ***\n");
                Employee joe = new Employee();
                Employee martin = new Employee("Martin", 23, 222222, 8);
                Console.WriteLine(Employee.p_empCompanyName);
                Employee.p_empCompanyName = "BOY COORP";
                Console.WriteLine(Employee.p_empCompanyName);
                martin.ssn = 22222;
                Console.WriteLine(martin.ssn);

             Console.WriteLine("**** Point class ***\n");
                Point p1 = new Point();
                p1.p_X = 10;
                p1.p_Y = 10;
                p1.DisplayStats();

                Point p2 = new Point(20, 20);
                p2.DisplayStats();

                Point p3 = new Point { p_Y = 20, p_X = 40, p_name = "Martin" };
                p3.DisplayStats();

            // Trigger to stop the program
            Console.ReadLine();
        }
Exemple #2
0
 public static decimal CalcTax(Employee E) 
 {
     return 0.08m * E.Salary;
 }
 private void btnEmployeeApp_Click(object sender, RoutedEventArgs e)
 {
     var newEmp = new Employee("Drozd", 178, 1500, 75, "10244");
     Console.WriteLine(@"SNN is: {0}", newEmp.SocialSecuretyNumber);
 }