Ejemplo n.º 1
0
 private void WritePesonExpense(CampingTrip trip, TextWriter tw)
 {
     for (var person = 1; person <= trip.NumberOfPeople; person++)
     {
         tw.WriteLine(trip.GetAmountOwedPerPerson(person) > 0 ? "$" + trip.GetAmountOwedPerPerson(person).ToString() : string.Format("(${0})", Math.Abs(trip.GetAmountOwedPerPerson(person)).ToString()));
     }
 }
Ejemplo n.º 2
0
 private void ProcessTrip(CampingTrip currentTrip, List <string> allLinesList)
 {
     for (var tripPersonID = 1; tripPersonID <= currentTrip.NumberOfPeople; tripPersonID++)
     {
         rowNumber++;
         ProcessExpensess(currentTrip, allLinesList, tripPersonID);
     }
 }
Ejemplo n.º 3
0
        private void ProcessExpensess(CampingTrip currentTrip, List <string> allLinesList, int tripPersonID)
        {
            int personNumberOfExpenses = Convert.ToInt32(allLinesList[rowNumber]);

            for (var personExpenseIndex = 1; personExpenseIndex <= personNumberOfExpenses; personExpenseIndex++)
            {
                rowNumber++;
                currentTrip.Expenses.Add(new Expense(tripPersonID, Convert.ToDecimal(allLinesList[rowNumber])));
            }
        }
Ejemplo n.º 4
0
        private IList <CampingTrip> ProcessFileContents(List <string> allLinesList)
        {
            bool isEndofFileContents = false;


            while (!isEndofFileContents)
            {
                if (Convert.ToInt32(allLinesList[rowNumber]) == 0)
                {
                    isEndofFileContents = true;
                    break;
                }

                CampingTrip currentTrip = new CampingTrip(Convert.ToInt32(allLinesList[rowNumber]));
                ProcessTrip(currentTrip, allLinesList);
                allTrips.Add(currentTrip);
                rowNumber++;
            }

            return(allTrips);
        }