Пример #1
0
        // Can make its on file
        static void Main(string[] args)
        {
            // Make a new comany
            var ColDotCom = new Company("Colliers.com");

            // Define new employees
            var tom    = new Employee("Tom", "Idiot", new DateTime());
            var john   = new Employee("John", "Smart", new DateTime());
            var tate   = new Employee("Tate", "Just ok", new DateTime());
            var remOve = new Employee("Mr Remove", "No Body", new DateTime());


            // Add the new employees
            ColDotCom.AddEmployee(tom);
            ColDotCom.AddEmployee(john);
            ColDotCom.AddEmployee(tate);
            ColDotCom.AddEmployee(remOve);

            // Remove an employee

            ColDotCom.RemoveEmployee(remOve);

            ColDotCom.AllEmployees();
            Console.ReadKey();
        }
Пример #2
0
    static void Main(string[] args)
    {
        // Create an instance of a company. Name it whatever you like.

        Company Tesla = new Company("Tesla", new DateTime(2008, 7, 14));

        Employee William = new Employee("William", "Kimball", "Chief", new DateTime(2012, 8, 14).ToString("dd/MM/yyyy"));
        Employee Sathvik = new Employee("Sathvik", "Reddy", "Other Chief", new DateTime(2014, 2, 03).ToString("dd/MM/yyyy"));
        Employee Natasha = new Employee("Natasha", "Cox", "Other Other Chief", new DateTime(2013, 6, 30).ToString("dd/MM/yyyy"));

        Tesla.AddEmployee(William);
        Tesla.Employees.Add(Sathvik);
        Tesla.AddEmployee(Natasha);

        foreach (Employee Name in Tesla.Employees)
        {
            Tesla.ListEmployees(Name);
        }

        //  Tesla.Employees.Add()

        // Create three employees

        // Assign the employees to the company

        /*
         *  Iterate the company's employee list and generate the
         *  simple report shown above
         */
    }
        public void Should_AddEmployee_WithDepartment_WhenFielsdAreSpecified()
        {
            Assert.That(_company.GetAllEmployees(Department.HumanResources).Count, Is.EqualTo(0));

            _company.AddEmployee(_employee);
            Assert.That(_company.GetAllEmployees(Department.HumanResources).Count, Is.EqualTo(1));
        }
Пример #4
0
        public void Should_GetEmployee_WhenFullNameIsSpecified()
        {
            _company.AddEmployee(_employee);
            var employee = _company.GetEmployeeByName(_employee.FirstName, _employee.LastName);

            Assert.That(employee, Is.EqualTo(_employee));
        }
Пример #5
0
    static void Main(string[] args)
    {
        // Create an instance of a company. Name it whatever you like.
        Company NSS = new Company("NSS", DateTime.Now);

        // Create three employees
        Employee brenda = new Employee("Brenda", "Long", "Lead Instructor", DateTime.Now);

        Employee kristen = new Employee("Kristen", "Norris", "Junior Instructor", DateTime.Now);

        Employee jeremiah = new Employee("Jeremiah", "Vasquez", "Student Relations", DateTime.Now);

        Employee chase = new Employee("Chase", "Fite", "TA", DateTime.Now);

        // Assign the employees to the company
        NSS.AddEmployee(jeremiah);
        NSS.AddEmployee(brenda);
        NSS.AddEmployee(kristen);
        NSS.AddEmployee(chase);

        /*
         *  Iterate the company's employee list and generate the
         *  simple report shown above
         */
        foreach (Employee employee in NSS.Employees)
        {
            Console.WriteLine($"{employee.firstName} {employee.lastName} works for {NSS.Name} as {employee.title}, and has since {employee.startTime}");
        }
    }
Пример #6
0
        public void AddEmployee_SameInstanceTwice_ThrowsException()
        {
            var company = new Company();
            var emp     = new WorkerA("John", 4000);

            company.AddEmployee(emp);
            Action act = () => company.AddEmployee(emp);

            act.Should().Throw <Exception>();
        }
Пример #7
0
        public void SingleResponsabilityTest()
        {
            var company = new Company();

            company.AddEmployee("Vittoria Zago");
            company.AddEmployee("John Doe");
            Console.WriteLine(company);

            Console.WriteLine("Day of work is valid: " + Work.IsValidDayOfWork(DateTime.Today));
        }
Пример #8
0
        static void Main(string[] args)
        {
            var drumWorks      = new Company("Drum Works", new DateTime());
            var vinnieCalaiuta = new Employee("Vinnie Calaiuta", "Chief Drumming Officer", new DateTime());
            var jackDejohnette = new Employee("Jack DeJohnette", "VP Jazz", new DateTime());
            var johnBonham     = new Employee("John Bonham", "CEO", new DateTime());

            drumWorks.AddEmployee(vinnieCalaiuta);
            drumWorks.AddEmployee(jackDejohnette);
            drumWorks.AddEmployee(johnBonham);

            drumWorks.ListEmployees();

            Console.ReadLine();
        }
Пример #9
0
        public void AddEmployee_Null_ThrowsArgNullException()
        {
            var    company = new Company();
            Action act     = () => company.AddEmployee(null);

            act.Should().Throw <ArgumentNullException>();
        }
        public async void Should_Add_New_Employee()
        {
            // given
            Company       company             = new Company("company_name_1");
            string        request             = JsonConvert.SerializeObject(company);
            StringContent requestBody         = new StringContent(request, Encoding.UTF8, "application/json");
            CompanyList   companyList         = new CompanyList();
            Employee      employee            = new Employee("Tom", 5000);
            string        employeeRequest     = JsonConvert.SerializeObject(employee);
            StringContent employeeRequestBody = new StringContent(employeeRequest, Encoding.UTF8, "application/json");

            // when
            await client.PostAsync("company/companies", requestBody);

            string companyId = "company_1";
            var    response  = await client.PostAsync($"company/companies/{companyId}/employees", employeeRequestBody);

            // then
            response.EnsureSuccessStatusCode();
            var responseString = await response.Content.ReadAsStringAsync();

            Employee actualEmployee = JsonConvert.DeserializeObject <Employee>(responseString);

            company.AddEmployee(employee);
            Assert.Equal(employee, actualEmployee);
        }
Пример #11
0
        public Employee AddEmployee(string companyId, Employee employee)
        {
            Company company = companies.GetCompanyByID(companyId);

            company.AddEmployee(employee);
            return(employee);
        }
Пример #12
0
    /*
     * System generation methods
     */

    private void SpawnShip()
    {
        // Get the position of the new ship
        Vector2 pos = new Vector2(Random.Range(0, planetSeperationDistance), Random.Range(0, planetSeperationDistance));

        pos += (Vector2)transform.position;

        // Create the ship from the prefab template and set its position
        GameObject newShip = Instantiate(shipTemplate);

        newShip.transform.position = pos;

        AssetLoader assets = FindObjectOfType <AssetLoader>();

        // Set the ship's data from json
        Ship shipComponent = newShip.GetComponent <Ship>();

        JsonUtility.FromJsonOverwrite(assets.shipData ["namean"], shipComponent);

        // Add it as an employee to the company
        Employee e = newShip.GetComponent <Employee>();

        transportCompany.AddEmployee(e);

        // Set up which contract types this employee can accept
        e.AddAcceptedContractType <FreightContract>();
    }
Пример #13
0
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        Company company = new Company();

        for (int i = 0; i < n; i++)
        {
            string[] line       = Console.ReadLine().Split(' ');
            string   name       = line[0];
            decimal  salary     = decimal.Parse(line[1]);
            string   position   = line[2];
            string   department = line[3];
            string   email      = "n/a";
            int      age        = -1;

            if (line.Length == 6)
            {
                email = line[4];
                age   = int.Parse(line.Last());
            }
            else if (line.Length == 5)
            {
                int  currAge = 0;
                bool isAge   = int.TryParse(line[4], out currAge);

                if (isAge)
                {
                    age = currAge;
                }
                else
                {
                    email = line[4];
                }
            }

            Employee newEmployee = new Employee
            {
                Age        = age,
                Department = department,
                Email      = email,
                Name       = name,
                Position   = position,
                Salary     = salary
            };

            company.AddEmployee(newEmployee);
        }
        IGrouping <string, Employee> result = company.GetDepartmentWithHighestSalary();

        Console.WriteLine($"Highest Average Salary: {result.Key}");

        foreach (var each in result.OrderByDescending(x => x.Salary))
        {
            Console.WriteLine($"{each.Name} {each.Salary:f2} {each.Email} {each.Age}");
        }
    }
Пример #14
0
        public void GetByWage_IncorectParameter_ThrowsArgException(double wage)
        {
            var company = new Company();
            var emp     = new WorkerA("John", 4000);

            company.AddEmployee(emp);
            Action act = () => company.GetByWage(wage);

            act.Should().Throw <ArgumentException>();
        }
Пример #15
0
        static void Main(string[] args)
        {
            var company = new Company("'I be M'");

            Console.WriteLine(company.OfficialIntroduction());

            var manager  = new Manager("Hugo Boss", new DateTime(1970, 5, 23));
            var regular1 = new Regular("Mr. Strong", new DateTime(1980, 2, 29), manager);
            var regular2 = new Regular("Ms. Good Looking", new DateTime(1990, 9, 2), manager);
            var regular3 = new Regular("Ms. Smart", new DateTime(1993, 10, 12), manager);
            var intern1  = new Intern("Slave", new DateTime(1995, 4, 30), manager, regular2);

            company.AddEmployee(manager);
            company.AddEmployee(regular1);
            company.AddEmployee(regular2);
            company.AddEmployee(regular3);
            company.AddEmployee(intern1);

            Console.WriteLine(company.OfficialIntroduction());

            var employeeId       = "R199310XX";
            var layOffSuccessful = company.LayOffEmployeeByEmployeeId(employeeId);

            Console.WriteLine(layOffSuccessful ? $"Employee with ID {employeeId} successfully fired!" : $"Employee with ID {employeeId} was not found!");

            employeeId       = "R19931012";
            layOffSuccessful = company.LayOffEmployeeByEmployeeId(employeeId);
            Console.WriteLine(layOffSuccessful ? $"Employee with ID {employeeId} successfully fired!" : $"Employee with ID {employeeId} was not found!");

            Console.WriteLine();

            Console.WriteLine(company.PromoteToRegular(intern1));

            Console.WriteLine();

            Console.WriteLine(company.OfficialIntroduction());
            Console.WriteLine(company.PromoteToManager(regular1));

            Console.WriteLine();

            Console.WriteLine(company.OfficialIntroduction());
            Console.ReadLine();
        }
Пример #16
0
        static void Main(string[] args)
        {
            var company   = new Company("PoopScoop Incorporated");
            var employee1 = new Employee("John", "Smith", "Data Analyst");
            var employee2 = new Employee("Janice", "Griffin", "Boss of All");
            var employee3 = new Employee("Jeff", "Tweedy", "Coffee Bitch");

            company.AddEmployee(employee1);
            company.AddEmployee(employee2);
            company.AddEmployee(employee3);
            company.ListEmployees();
            employee1.eat();
            employee1.eat();
            employee1.eat();
            employee1.eat();
            employee1.eat();
            employee1.eat(company._currentEmployees);
            employee2.eat("Chicken");
            employee3.eat("Steak", company._currentEmployees);
        }
Пример #17
0
 public void AddInitialCompanyAndUser()
 {
     Assembly assembly = Assembly.Load("StoryVerse.Core");
     ActiveRecordStarter.Initialize(assembly,
         ActiveRecordSectionHandler.Instance);
     Company c = new Company();
     c.Name = "getin";
     Person p = new Person();
     p.FirstName = "Get";
     p.LastName = "In";
     p.Username = "******";
     p.Password = "******";
     p.IsAdmin = true;
     c.AddEmployee(p);
     c.CreateAndFlush();
 }
        public override string Execute()
        {
            foreach (IOrganizationalUnit c
                in this.db.Companies)
            {
                if (c.Name == this.companyName)
                {
                    throw new Exception(string.Format("Company {0} already exists", this.companyName));
                }
            }

            IOrganizationalUnit company = new Company(this.companyName);
            IEmployee ceo = EmployeeFactory.Create(this.ceoFirstName, this.ceoLastName, "CEO", company, this.ceoSalary);
            this.db.AddCompany(company);
            company.AddEmployee(ceo);
            company.Head = ceo;
            return "";
        }
Пример #19
0
        public override string Execute()
        {
            foreach (var c
                     in this.db.Companies)
            {
                if (c.Name == this.companyName)
                {
                    throw new Exception(string.Format("Company {0} already exists", this.companyName));
                }
            }

            IOrganizationalUnit company = new Company(this.companyName);
            var ceo = EmployeeFactory.Create(this.ceoFirstName, this.ceoLastName, "CEO", company, this.ceoSalary);

            this.db.AddCompany(company);
            company.AddEmployee(ceo);
            company.Head = ceo;
            return("");
        }
Пример #20
0
    private void SpawnPlanet(int planetNumber, int maxPlanets)
    {
        // Get a random position for the planet.
        // Note that the distance from the star is set based on how many planets have been generated already
        // and the planet seperation distance.
        Vector2 pos = Random.insideUnitCircle;

        pos.Normalize();
        pos *= (planetSeperationDistance * (planetNumber + 1));

        // Create the planet from the prefab template and set its position
        GameObject newPlanet = Instantiate(planetTemplate, transform);

        newPlanet.transform.parent = gameObject.transform;
        newPlanet.transform.Translate(pos);

        // Give the planet a sprite and a name
        GiveSprite(newPlanet);
        newPlanet.name = name + " " + (planetNumber + 1);

        // Create resource, storage and production nodes to be added to the planet
        StorageNode    newSNode = Instantiate(storageNodeTemplate, newPlanet.transform).GetComponent <StorageNode>();
        ResourceNode   newRNode = Instantiate(resourceNodeTemplates[Random.Range(0, resourceNodeTemplates.Length)], newPlanet.transform).GetComponent <ResourceNode>();
        ProductionNode newPNode = Instantiate(factoryTemplates[Random.Range(0, factoryTemplates.Length)], newPlanet.transform).GetComponent <ProductionNode>();

        // Connect the industry nodes to the storage node.
        newRNode.connectedStorageNode = newSNode;
        newPNode.connectedStorageNode = newSNode;

        // Give the company ownership of the nodes
        productionCompany.AddEmployee(newSNode.gameObject.GetComponent <Employee>());
        productionCompany.AddEmployee(newRNode.gameObject.GetComponent <Employee>());
        productionCompany.AddEmployee(newPNode.gameObject.GetComponent <Employee>());

        // Add the industry nodes to the planet
        Planet planetScript = newPlanet.GetComponent <Planet> () as Planet;

        planetScript.industryNodes.Add(newRNode);
        planetScript.industryNodes.Add(newPNode);
        planetScript.industryNodes.Add(newSNode);

        planets.Add(planetScript);

        // Spawn a moon if our random number is 0
        if (Random.Range(0, 5) == 0)
        {
            SpawnMoon(newPlanet);
        }
    }
Пример #21
0
        public void UpgradeRole()
        {
            foreach (var init in this.Inits)
            {
                init();
                this.Populate();

                Company acme = Company.Create(this.Session, "Acme");
                Company acne = Company.Create(this.Session, "Acne");

                Person john = Person.Create(this.Session, "John", 2);
                Person jane = Person.Create(this.Session, "Jane", 1);

                Person johny = Person.Create(this.Session, "Johny", 4);
                Person janet = Person.Create(this.Session, "Janet", 3);

                // One 2 Many
                acme.AddEmployee(john);
                acme.AddEmployee(jane);

                acne.AddEmployee(johny);

                Extent employees = acme.Employees;

                Assert.AreEqual(2, employees.Count);

                employees.Filter.AddLike(MetaNamed.Instance.Name, "Ja%");

                Assert.AreEqual(1, employees.Count);

                employees = acme.Employees;

                Assert.AreEqual(2, employees.Count);

                employees.AddSort(MetaNamed.Instance.Index, SortDirection.Descending);

                Assert.AreEqual(2, employees.Count);
                Assert.AreEqual(john, employees[0]);
                Assert.AreEqual(jane, employees[1]);

                // Many to Many
                acme.AddOwner(john);
                acme.AddOwner(jane);

                acne.AddOwner(jane);
                acne.AddOwner(johny);

                Extent acmeOwners = acme.Owners;
                Extent acneOwners = acme.Owners;

                acmeOwners.Filter.AddLike(MetaNamed.Instance.Name, "Ja%");

                Assert.AreEqual(1, acmeOwners.Count);

                acmeOwners = acme.Owners;

                Assert.AreEqual(2, acmeOwners.Count);

                acmeOwners.AddSort(MetaNamed.Instance.Index);

                Assert.AreEqual(2, acmeOwners.Count);
                Assert.AreEqual(jane, acmeOwners[0]);
                Assert.AreEqual(john, acmeOwners[1]);
            }
        }
Пример #22
0
        private void CreateCompanyList()
        {
            _companyList = new List <Company>();
            Company company1 = new Company()
            {
                Name = "Лапоть"
            };

            company1.AddEmployee(new Employee()
            {
                FIO = "Свиридов Иван Афанасьевич"
            });
            company1.AddEmployee(new Employee()
            {
                FIO = "Смирнов Константин Олегович"
            });
            company1.AddEmployee(new Employee()
            {
                FIO = "Приходько Кондрат Виниаминович"
            });
            _companyList.Add(company1);
            Company company2 = new Company()
            {
                Name = "Корат"
            };

            company2.AddEmployee(new Employee()
            {
                FIO = "Иваськова Таисия Алексеевна"
            });
            company2.AddEmployee(new Employee()
            {
                FIO = "Уварова Ефросинья Фёдоровна"
            });
            company2.AddEmployee(new Employee()
            {
                FIO = "Замулина Миланья Пафнутьевна"
            });
            _companyList.Add(company2);
            Company company3 = new Company()
            {
                Name = "Омега"
            };

            company3.AddEmployee(new Employee()
            {
                FIO = "Жлобова Авдотья Петровна"
            });
            company3.AddEmployee(new Employee()
            {
                FIO = "Акеньшина Пелагея Игнатова"
            });
            company3.AddEmployee(new Employee()
            {
                FIO = "Целиков Пётр Леонидович"
            });
            _companyList.Add(company3);
            Company company4 = new Company()
            {
                Name = "Железный занавес"
            };

            company4.AddEmployee(new Employee()
            {
                FIO = "Шмаков Артём Игоревич"
            });
            _companyList.Add(company4);
            ISessionProvider factory    = new SessionProvider();
            IUnitOfWork      unitOfWork = factory.CurrentUoW;
            IRepository      repository = new Repository(unitOfWork);

            unitOfWork.BeginTransaction();
            foreach (Company companyItem in _companyList)
            {
                repository.AddEntity <Company>(companyItem);
            }
            unitOfWork.CommitTransaction();
        }
Пример #23
0
        static void Main(string[] args)
        {
            var      companyName     = "Big Bernie's House Of Tuna";
            var      coCreatedOn     = "7/4/2010";
            DateTime companyGoesLive = Convert.ToDateTime(coCreatedOn);

            Console.WriteLine("What's your first name?");
            var firstNameInput = Console.ReadLine();

            Console.WriteLine("What's your last name?");
            var lastNameInput = Console.ReadLine();

            Console.WriteLine("What do you want your job title to be?");
            var jobTitle = Console.ReadLine();

            var myCompany = new Company(companyName, companyGoesLive);

            myCompany.AddEmployee(firstNameInput, lastNameInput, jobTitle);

            Console.WriteLine("What's your first name?");
            var firstNameInput2 = Console.ReadLine();

            Console.WriteLine("What's your last name?");
            var lastNameInput2 = Console.ReadLine();

            Console.WriteLine("What do you want your job title to be?");
            var jobTitle2 = Console.ReadLine();

            myCompany.AddEmployee(firstNameInput2, lastNameInput2, jobTitle2);

            Console.WriteLine("What's your first name?");
            var firstNameInput3 = Console.ReadLine();

            Console.WriteLine("What's your last name?");
            var lastNameInput3 = Console.ReadLine();

            Console.WriteLine("What do you want your job title to be?");
            var jobTitle3 = Console.ReadLine();

            myCompany.AddEmployee(firstNameInput3, lastNameInput3, jobTitle3);

            myCompany.showCurrentEmployees();
            Console.WriteLine("Wanna remove an employee who no longer works for this sweet company? What number in the list is it? (or press n)");
            var numRespEmpToRemove = Console.ReadLine();

            if (numRespEmpToRemove == "1")
            {
                myCompany.RemoveEmployee(0);
                myCompany.showCurrentEmployees();
            }
            if (numRespEmpToRemove == "2")
            {
                myCompany.RemoveEmployee(1);
                myCompany.showCurrentEmployees();
            }
            if (numRespEmpToRemove == "3")
            {
                myCompany.RemoveEmployee(2);
                myCompany.showCurrentEmployees();
            }
            else
            {
            }
        }