コード例 #1
0
        static void Main(string[] args)
        {
            List <TimeSheetEntryModels> timeSheetEntries = GetTimeSheetEntries();

            List <CustomerModel> customers = CustomerLibrary.GetCustomers();

            foreach (var customer in customers)
            {
                var customerTime = TimeSheetProcessor.CalculateTimeForCustomer(timeSheetEntries, customer.Name);
                SimulateSendingMail(customer, customerTime);
            }

            List <PaymentModel> payments = PaymentLibrary.GetPayments();



            var timeWorked = TimeSheetProcessor.CalculateTimeWorked(timeSheetEntries);

            foreach (var paymentModel in payments)
            {
                if (timeWorked > paymentModel.HourLimit)
                {
                    SimulatePayment(paymentModel, timeWorked);
                    break;
                }
            }

            Console.WriteLine();
            Console.Write("Press any key to exit application...");
            Console.ReadKey();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            string workDone;
            int    hourDone;
            int    timeTotal;

            List <TimeSheetEntryModel> timeSheetEntries = new List <TimeSheetEntryModel>();
            List <CustomerModel>       customer         = new List <CustomerModel>
            {
                new CustomerModel {
                    Name = "Acme", HourlyRate = 150
                },
                new CustomerModel {
                    Name = "ABC", HourlyRate = 125
                }
            };


            bool continueEntering;

            do
            {
                Console.Write("Enter what you did: ");
                workDone = Console.ReadLine();

                Console.Write("How long did you do it for(in hours): ");
                hourDone = int.Parse(Console.ReadLine());

                TimeSheetEntryModel entry = new TimeSheetEntryModel
                {
                    HoursWorked = hourDone,
                    WorkDone    = workDone
                };
                timeSheetEntries.Add(entry);

                Console.Write("Do you want to enter more time:");
                continueEntering = Console.ReadLine().ToLower() == "yes";
                //continueEntering = Console.ReadLine().Equals("yes", StringComparison.OrdinalIgnoreCase);
            }while (continueEntering == true);



            timeTotal = TimeSheetProcessor.CalculateTimeForCustomer(timeSheetEntries, "Acme");
            Console.WriteLine("Simulating Sending email to Acme");
            Console.WriteLine("Your bill is $" + timeTotal * 150 + " for the hours worked.");

            timeTotal = TimeSheetProcessor.CalculateTimeForCustomer(timeSheetEntries, "ABC");
            Console.WriteLine("Simulating Sending email to ABC");
            Console.WriteLine("Your bill is $" + timeTotal * 125 + " for the hours worked.");
            for (int i = 0; i < timeSheetEntries.Count; i++)
            {
                timeTotal += timeSheetEntries[i].HoursWorked;
            }
            if (timeTotal > 40)
            {
                Console.WriteLine("You will get paid $" + timeTotal * 15 + " for your work.");
            }
            else
            {
                Console.WriteLine("You will get paid $" + timeTotal * 10 + " for your time.");
            }
            Console.WriteLine();
            Console.Write("Press any key to exit application...");
            Console.ReadKey();
        }