//Calculating monthly wages for different companies
        public int ComputeEmpWage(EmpWageBuilder empWageBuilder)
        {
            int totalEmpHours     = 0;
            int days              = 0;
            int empHours          = 0;
            int totalWagePerDay   = 0;
            int totalWagePerMonth = 0;

            while (totalEmpHours < empWageBuilder.maxHours && days < empWageBuilder.workingDays)
            {
                EmpWageCalc empWageCalc = new EmpWageCalc();
                empHours = empWageCalc.GetWorkingHours();

                if (totalEmpHours == 96)
                {
                    empHours = 4;
                }
                if (empHours != 0)
                {
                    days++;
                    totalEmpHours      = empHours + totalEmpHours;
                    totalWagePerDay    = empHours * empWageBuilder.dWage;
                    totalWagePerMonth += totalWagePerDay;
                    Console.WriteLine("Total Wage per Day.." + totalWagePerDay);
                }
            }
            return(totalWagePerMonth);
        }
        public int ComputeEmpWage(CompanyEmpWage companyEmpWage)
        {
            int totalEmpHours     = 0;
            int workingDays       = 0;
            int empHours          = 0;
            int totalWagePerDay   = 0;
            int totalWagePerMonth = 0;

            while (totalEmpHours < companyEmpWage.maxHoursPerMonth && workingDays < companyEmpWage.numOfWorkingDays)
            {
                EmpWageBuilder empWageBuilder = new EmpWageBuilder();
                empHours = empWageBuilder.GetWorkingHours();

                if (totalEmpHours == 96)
                {
                    empHours = 4;
                }
                if (empHours != 0)
                {
                    workingDays++;
                    totalEmpHours      = empHours + totalEmpHours;
                    totalWagePerDay    = empHours * companyEmpWage.ratePerHours;
                    totalWagePerMonth += totalWagePerDay;
                    Console.WriteLine("Total Wage per Day.." + totalWagePerDay);
                }
            }
            return(totalWagePerMonth);
        }
        //Adding different company details
        public void AddCompanyWage(string company, int dWage, int totalWorkingHours, int workingDays, int maxHours)
        {
            EmpWageBuilder empWageBuilder = new EmpWageBuilder(company, dWage, totalWorkingHours, workingDays, maxHours);

            this.companyWageList.AddLast(empWageBuilder);
            this.companyToEmpWageMap.Add(company, empWageBuilder);
        }
Exemple #4
0
        static void Main(string[] args)
        {
            EmpWageBuilder empWageBuilder = new EmpWageBuilder();

            empWageBuilder.AddCompanyEmpWage("Dmart", 20, 2, 20);
            empWageBuilder.AddCompanyEmpWage("Reliance", 15, 14, 40);
            empWageBuilder.ComputeEmpWage();
            Console.WriteLine("Total wage for Dmart is: " + empWageBuilder.GetTotalWage("Dmart"));
            Console.ReadKey();
        }