Пример #1
0
        static void Main(string[] args)
        {
            SalaryEmployee sEmployee  = new SalaryEmployee("David", "Barnes", new DateTime(2014, 10, 31), 537.36m);
            SalaryEmployee sEmployee2 = new SalaryEmployee();

            //Output the SalaryEmployee converted to a string
            Console.WriteLine(sEmployee.ToString());
            Console.WriteLine(sEmployee2.ToString());

            HourlyEmployee hEmployee = new HourlyEmployee("Joe", "Smith", new DateTime(2013, 10, 01), 12.43m, 36m);

            Console.WriteLine(hEmployee.ToString());
            Console.WriteLine(hEmployee.GetYearlySalary());
            Console.WriteLine(hEmployee.GetAllEmployeeInformation());

            //Declare a new colletion
            IEmployeeCollection employeeCollection;

            //Instanciate the collection with the concreate class even though it is going into
            //an interface container
            employeeCollection = new EmployeeCollection();
            //Call the method below to add the employees to the collection
            AddNewEmployees(employeeCollection);

            //Print the employees out
            PrintEmployees(employeeCollection);
        }
        public void Test_Salary_Returns_Yearly_Salary()
        {
            //Alternate without the using cis237inclass3 statement
            //cis237inclass3.HourlyEmployee hourlyEmployee2 = new HourlyEmployee("David", "Barnes", 10.00m);

            HourlyEmployee hourlyEmployee = new HourlyEmployee("David", "Barnes", 10.00m);
            Assert.AreEqual(20800.00m, hourlyEmployee.Salary);
            Assert.IsInstanceOfType(hourlyEmployee, typeof(HourlyEmployee));
            //Assert.AreEqual(true, true);
            //Assert.AreNotEqual(false, true);
        }
Пример #3
0
        static void Main(string[] args)
        {
            // Employee employee = new Employee();
            SalaryEmployee sEmployees = new SalaryEmployee("Kyle", "Sherman", new DateTime(2014, 10, 31), 1000.01m);

            //Console.WriteLine(sEmployees.GetAllEmployeeInformation().ToString());
            Console.WriteLine(sEmployees.ToString());
            //SalaryEmployee sEmployee2 = new SalaryEmployee();
            //Console.WriteLine(sEmployees.nameAndSalary());

            HourlyEmployee hEmployee1 = new HourlyEmployee("Steve", "MahBoi", new DateTime(2013, 10, 31), 1000.01m, 40);

            //Console.WriteLine(hEmployee1.GetAllEmployeeInformation().ToString());
            Console.WriteLine(hEmployee1.ToString());
            Console.WriteLine(hEmployee1.GetYearlySalary());
            Console.WriteLine(hEmployee1.GetAllEmployeeInformation());
        }
Пример #4
0
        static void Main(string[] args)
        {            
            SalaryEmployee salaryEmployee1 = new SalaryEmployee("Billy", "Bob", 40000.34m);

            HourlyEmployee hourlyEmployee1 = new HourlyEmployee("Rick", "James", 49.99m);

            //Creat simple int that will be used for value vs reference            

            //Write the value of the int before the method, call the method, print after call.            
            //Write the value of the employee before the method, call the method, print after call.            
            Console.WriteLine(salaryEmployee1.ToString());
            Console.WriteLine(hourlyEmployee1.ToString());
            
            //Console.WriteLine(employee.GetFullName());
            //Console.WriteLine(employee.ToString());

            //Showing how to use an array with objects
            IEmployee[] employees = new Employee[10];

            
            //Instanciate some employees into the array
            employees[0] = new HourlyEmployee("James", "Kirk", 14.05m);
            employees[1] = new SalaryEmployee("Jean-Luc", "Picard", 55273.00m);
            employees[2] = new HourlyEmployee("Benjamin", "Sisko", 14.59m);
            employees[3] = new SalaryEmployee("Kathryn", "Janeway", 67123);
            employees[4] = new SalaryEmployee("Johnathan", "Archer", 12232);
            employees[5] = new HourlyEmployee("James", "Kirk",12.05m);
            employees[6] = new SalaryEmployee("Jean-Luc", "Picard", 55123.00m);
            employees[7] = new HourlyEmployee("Benjamin", "Sisko", 14.56m);
            employees[8] = new SalaryEmployee("Kathryn", "Janeway",67000);
            employees[9] = new SalaryEmployee("Johnathan", "Archer", 12000);            

            //Lets use the new CSVProcessor we made!
            //CSVProcessor csvProcesor = new CSVProcessor();

            //Call the ImportCSV method passing the path, and the employees array
            //over so they can be used.
            //csvProcesor.ImportCSV("../data/employees.csv", employees);

            //A for each loop that will loop through each element of the employees array
            foreach (Employee employee in employees)
            {
                //Check to make sure that the current object is not null.
                //we know that the first 5 have values because we assigned them right above
                //but the last 5 are null, so we better put in a check.
                if (employee != null)
                {
                    //output the information of the employee
                    Console.WriteLine(employee.ToString());
                }
            }

            //We are creating a new UserInterface class, and it's okay
            //that the UserInterface class does not have a defined
            //constructor. It will have a default one provide to us that
            //we can take advantage of by just not passing in any parameters
            UserInterface ui = new UserInterface();

            //This is not a valid statement. Because we are trying to make
            //an instance of a static class, it won't work.
            //StaticUserInterface stui = new StaticUserInterface();

            //Call the GetUserInput method of the UI class. It will return
            //a valid integer that represents the choice they want to do.
            int choice = ui.GetUserInput();

            //To use a static class to execute methods we simply call the
            //method on the class name, (or type). Since it is not possible
            //to use the 'new' keyword and make an instance, the only way
            //we can access the class is through the class name, so that
            //is what we do. Here we are calling the GetUserInterface method
            //on the class name to get it to run.
            //choice = StaticUserInterface.GetUserInput();

            //While the choice is not the exit choice (which in this case is 2)
            while (choice != 2)
            {
                //If the choice is 1, which in this case it has to be, but if there
                //were more menu options it might not be so obvious.
                if (choice == 1)
                {
                    //Create a empty string to concat to.
                    string allOutput = "";
                    //For each Employee in the employees array.
                    foreach (Employee employee in employees)
                    {
                        //So long as the spot in the array is not null
                        if (employee != null)
                        {
                            //Concat the employee changed to a string plus a new line
                            //to the allOutput string.
                            allOutput += employee.ToString() + Environment.NewLine;
                        }
                    }
                    //Now that the large string containing what I would like to output
                    //is created, I can output it to the screen using the
                    //PrintAllOutput method of the UI class.
                    ui.PrintAllOutput(allOutput);
                }

                //Now that the "Work" that we wanted to do is done,
                //We need to re-prompt the user for some input
                choice = ui.GetUserInput();
            }





        }        
Пример #5
0
        static void Main(string[] args)
        {
            //Showing how to use an array with objects
            IEmployee[] employees = new Employee[10];
            
            //Instanciate some employees into the array
            employees[0] = new HourlyEmployee("James", "Kirk", 14.05m);
            employees[1] = new SalaryEmployee("Jean-Luc", "Picard", 55273.00m);
            employees[2] = new HourlyEmployee("Benjamin", "Sisko", 14.59m);
            employees[3] = new SalaryEmployee("Kathryn", "Janeway", 67123);
            employees[4] = new SalaryEmployee("Johnathan", "Archer", 12232);

            employees[5] = new HourlyEmployee("James", "Kirk", 12.05m);
            employees[6] = new SalaryEmployee("Jean-Luc", "Picard", 55123.00m);
            employees[7] = new HourlyEmployee("Benjamin", "Sisko", 14.56m);
            employees[8] = new SalaryEmployee("Kathryn", "Janeway", 67000);
            employees[9] = new SalaryEmployee("Johnathan", "Archer", 12000);
           

            //We are creating a new UserInterface class, and it's okay
            //that the UserInterface class does not have a defined
            //constructor. It will have a default one provide to us that
            //we can take advantage of by just not passing in any parameters
            UserInterface ui = new UserInterface();

            //This is not a valid statement. Because we are trying to make
            //an instance of a static class, it won't work.
            //StaticUserInterface stui = new StaticUserInterface();

            //Call the GetUserInput method of the UI class. It will return
            //a valid integer that represents the choice they want to do.
            int choice = ui.GetUserInput();

            //To use a static class to execute methods we simply call the
            //method on the class name, (or type). Since it is not possible
            //to use the 'new' keyword and make an instance, the only way
            //we can access the class is through the class name, so that
            //is what we do. Here we are calling the GetUserInterface method
            //on the class name to get it to run.
            //choice = StaticUserInterface.GetUserInput();

            //While the choice is not the exit choice (which in this case is 2)
            while (choice != 2)
            {
                //If the choice is 1, which in this case it has to be, but if there
                //were more menu options it might not be so obvious.
                if (choice == 1)
                {
                    //Create a empty string to concat to.
                    string allOutput = "";
                    //For each Employee in the employees array.
                    foreach (Employee employee in employees)
                    {
                        //So long as the spot in the array is not null
                        if (employee != null)
                        {
                            //Concat the employee changed to a string plus a new line
                            //to the allOutput string.
                            allOutput += employee.ToString() + Environment.NewLine;
                        }
                    }
                    //Now that the large string containing what I would like to output
                    //is created, I can output it to the screen using the
                    //PrintAllOutput method of the UI class.
                    ui.PrintAllOutput(allOutput);
                }

                //Now that the "Work" that we wanted to do is done,
                //We need to re-prompt the user for some input
                choice = ui.GetUserInput();
            }
        }
 public void TestSalaryReturnsYearlySalary()
 {
     HourlyEmployee hourlyEmloyee = new HourlyEmployee("Steven", "Johnson", 10.00m);
     Assert.AreEqual(20800m, hourlyEmloyee.Salary);
     Assert.IsInstanceOfType(hourlyEmloyee, typeof(HourlyEmployee));
 }
Пример #7
0
 public void Test_Salary_Returns_Yearly_Salary()
 {
     HourlyEmployee hourlyEmployee = new HourlyEmployee("Joshua", "Sziede", 10.00m);
     Assert.AreEqual(20800.00m, hourlyEmployee.Salary);
     Assert.IsInstanceOfType(hourlyEmployee, typeof(HourlyEmployee));
 }
Пример #8
0
        static void Main(string[] args)
        {
            // this is a test!

            // only to explain the branching

            //Create a couple of instances of the Employee class
            Employee employee1 = new Employee("Dave", "Barnes");
            Employee employee2 = new Employee("Joe", "Somebody");

            SalaryEmployees salaryEmployee1 = new SalaryEmployees("Paul", "Bath", 55000m);


            //Creat simple int that will be used for value vs reference
            int myNumber = 5;

            //Write the value of the int before the method, call the method, print after call.
            Console.WriteLine(myNumber);
            changeAnInt(myNumber);
            Console.WriteLine(myNumber);

            //Write the value of the employee before the method, call the method, print after call.
            Console.WriteLine(employee1.ToString());
            changeAnObject(employee1);
            Console.WriteLine(employee1.ToString());

            //Console.WriteLine(employee.GetFullName());
            //Console.WriteLine(employee.ToString());

            //Showing how to use an array with objects
            Employee[] employees = new Employee[10];


            //Instanciate some employees into the array

            employees[0] = new HourlyEmployee("James", "Kirk", 550m);
            // we can store child parameter objects in an array of the parent array
            employees[1] = new SalaryEmployees("Jean-Luc", "Picard", 2225.21m);
            employees[2] = new Employee("Benjamin", "Sisko");
            employees[3] = new Employee("Kathryn", "Janeway");
            employees[4] = new Employee("Johnathan", "Archer");

            employees[5] = new HourlyEmployee("James", "Kirk", 550m);
            employees[6] = new SalaryEmployees("Jean-Luc", "Picard", 2225.21m);
            employees[7] = new Employee("Benjamin", "Sisko");
            employees[8] = new Employee("Kathryn", "Janeway");
            employees[9] = new Employee("Johnathan", "Archer");

            ////Lets use the new CSVProcessor we made!
            //CSVProcessor csvProcesor = new CSVProcessor();

            ////Call the ImportCSV method passing the path, and the employees array
            ////over so they can be used.
            //csvProcesor.ImportCSV("../data/employees.csv", employees);

            ////A for each loop that will loop through each element of the employees array
            foreach (Employee employee in employees)
            {
                //Check to make sure that the current object is not null.
                //we know that the first 5 have values because we assigned them right above
                //but the last 5 are null, so we better put in a check.
                if (employee != null)
                {
                    //output the information of the employee
                    Console.WriteLine(employee.ToString());
                }
            }

            // Print out the new subClasses of EMployee
            Console.WriteLine("\n" + salaryEmployee1.ToString() + "\n");

            //We are creating a new UserInterface class, and it's okay
            //that the UserInterface class does not have a defined
            //constructor. It will have a default one provide to us that
            //we can take advantage of by just not passing in any parameters
            UserInterface ui = new UserInterface();

            //This is not a valid statement. Because we are trying to make
            //an instance of a static class, it won't work.
            //StaticUserInterface stui = new StaticUserInterface();

            //Call the GetUserInput method of the UI class. It will return
            //a valid integer that represents the choice they want to do.
            int choice = ui.GetUserInput();

            //To use a static class to execute methods we simply call the
            //method on the class name, (or type). Since it is not possible
            //to use the 'new' keyword and make an instance, the only way
            //we can access the class is through the class name, so that
            //is what we do. Here we are calling the GetUserInterface method
            //on the class name to get it to run.
            //choice = StaticUserInterface.GetUserInput();

            //While the choice is not the exit choice (which in this case is 2)
            while (choice != 2)
            {
                //If the choice is 1, which in this case it has to be, but if there
                //were more menu options it might not be so obvious.
                if (choice == 1)
                {
                    //Create a empty string to concat to.
                    string allOutput = "";
                    //For each Employee in the employees array.
                    foreach (Employee employee in employees)
                    {
                        //So long as the spot in the array is not null
                        if (employee != null)
                        {
                            //Concat the employee changed to a string plus a new line
                            //to the allOutput string.
                            allOutput += employee.ToString() + Environment.NewLine;
                        }
                    }
                    //Now that the large string containing what I would like to output
                    //is created, I can output it to the screen using the
                    //PrintAllOutput method of the UI class.
                    ui.PrintAllOutput(allOutput);
                }

                //Now that the "Work" that we wanted to do is done,
                //We need to re-prompt the user for some input
                choice = ui.GetUserInput();
            }
        }
Пример #9
0
        static void Main(string[] args)
        {
            //Make a new instance of the User Interface class
            UserInterface ui = new UserInterface();

            //Let's make an array to hold a bunch of instances of the Employee class
            IEmployee[] employees = new IEmployee[10];

            //Let's add some employees to our array
            employees[0] = new SalaryEmployee("David", "Barnes", 835.00m);
            employees[1] = new SalaryEmployee("James", "Kirk", 453.00m);
            employees[2] = new SalaryEmployee("Jean-Luc", "Picard", 290.00m);
            employees[3] = new HourlyEmployee("Benjamin", "Sisko", 40m, 26.00m);
            employees[4] = new HourlyEmployee("Kathryn", "Janeway", 20m, 15.00m);
            employees[5] = new SalaryEmployee("Johnathan", "Archer", 135.00m);

            //Make a index for the next open spot in the array
            int nextOpen = 6;

            //Get some input from the user
            int choice = ui.GetUserInput();

            //While the choice they selected is not 2, continue to do work
            while (choice != 3)
            {
                //See if the input they sent is equal to 1.
                if (choice == 1)
                {
                    //Create a string that can be concated to
                    string outputString = "";

                    //Print out the employees in the array
                    foreach (IEmployee employee in employees)
                    {
                        if (employee != null)
                        {
                            //Concat to the outputString
                            outputString += employee.ToString() +
                                            " " + employee.GetFormattedSalary() +
                                            Environment.NewLine;
                        }
                    }

                    //Use the UI class to print out the string
                    ui.Output(outputString);
                }

                //If we are doing the clone employee option
                if (choice == 2)
                {
                    //Make a clone of the first employee
                    IEmployee clone = getClonedObject(employees[0]);

                    //Put the cloned employee into the next empty spot
                    employees[nextOpen++] = clone;
                }

                //re-prompt the user for input
                choice = ui.GetUserInput();
            }
        }
 public void Test_Salary_Returns_Yearly_Salary()
 {
     HourlyEmployee hourlyEmployee = new HourlyEmployee("David", "Letterman", 10.00m);
     Assert.AreEqual(20800.00m, hourlyEmployee.Salary);
     Assert.IsInstanceOfType(hourlyEmployee, typeof(HourlyEmployee));
 }
Пример #11
0
        static void Main(string[] args)
        {
            //Showing how to use an array with objects
            //Parent class Employee can use child classes HourlyEmployee and SalaryEmployee
            IEmployee[] employees = new Employee[10];

            //Instanciate some employees into the array
            employees[0] = new SalaryEmployee("James", "Kirk", 12345m);
            employees[1] = new HourlyEmployee("Jean-Luc", "Picard", 12.25m);
            employees[2] = new HourlyEmployee("ayy", "lmao", 123.05m);
            employees[3] = new SalaryEmployee("y", "ee", 55123.00m);
            employees[4] = new HourlyEmployee("Benjamin", "Sisko", 42.13m);
            employees[5] = new SalaryEmployee("Kathryn", "Janeway", 14567m);
            employees[6] = new HourlyEmployee("Johnathan", "Archer", 21.12m);

            //We are creating a new UserInterface class, and it's okay
            //that the UserInterface class does not have a defined
            //constructor. It will have a default one provide to us that
            //we can take advantage of by just not passing in any parameters
            UserInterface ui = new UserInterface();

            //This is not a valid statement. Because we are trying to make
            //an instance of a static class, it won't work.
            //StaticUserInterface stui = new StaticUserInterface();

            //Call the GetUserInput method of the UI class. It will return
            //a valid integer that represents the choice they want to do.
            int choice = ui.GetUserInput();

            //To use a static class to execute methods we simply call the
            //method on the class name, (or type). Since it is not possible
            //to use the 'new' keyword and make an instance, the only way
            //we can access the class is through the class name, so that
            //is what we do. Here we are calling the GetUserInterface method
            //on the class name to get it to run.
            //choice = StaticUserInterface.GetUserInput();

            //While the choice is not the exit choice (which in this case is 2)
            while (choice != 2)
            {
                //If the choice is 1, which in this case it has to be, but if there
                //were more menu options it might not be so obvious.
                if (choice == 1)
                {
                    //Create a empty string to concat to.
                    string allOutput = "";
                    //For each Employee in the employees array.
                    foreach (Employee employee in employees)
                    {
                        //So long as the spot in the array is not null
                        if (employee != null)
                        {
                            //Concat the employee changed to a string plus a new line
                            //to the allOutput string.
                            allOutput += employee.ToString() + Environment.NewLine;
                        }
                    }
                    //Now that the large string containing what I would like to output
                    //is created, I can output it to the screen using the
                    //PrintAllOutput method of the UI class.
                    ui.PrintAllOutput(allOutput);
                }

                //Now that the "Work" that we wanted to do is done,
                //We need to re-prompt the user for some input
                choice = ui.GetUserInput();
            }
        }
Пример #12
0
 public void add(string FirstName, string LastName, DateTime StartDate, decimal HourlyRate, decimal HoursPerWeek)
 {
     employees[currentIndex++] = new HourlyEmployee(FirstName, LastName, StartDate, HourlyRate, HoursPerWeek);
 }