コード例 #1
0
        internal void calcFinalTotals(List aList, List vList, List mList)
        {
            aCommunalTotalPerPerson = aList.returnCommunalTotal() / 3;
            vCommunalTotalPerPerson = vList.returnCommunalTotal() / 3;
            mCommunalTotalPerPerson = mList.returnCommunalTotal() / 3;
            amountVOwesA = aList.returnVListTotal() + aCommunalTotalPerPerson;
            amountMOwesA = aList.returnMListTotal() + aCommunalTotalPerPerson;
            amountAOwesV = vList.returnAListTotal() + vCommunalTotalPerPerson;
            amountMOwesV = vList.returnMListTotal() + vCommunalTotalPerPerson;
            amountAOwesM = mList.returnAListTotal() + mCommunalTotalPerPerson;
            amountVOwesM = mList.returnVListTotal() + mCommunalTotalPerPerson;

            // Now to compare each person's dues to the other person's dues.
            Console.WriteLine("\nComparing amounts owed to amounts due for each person...");
            if (amountVOwesA >= amountAOwesV) {
                amountVOwesA -= amountAOwesV;
                amountAOwesV = 0;
            }
            else if (amountVOwesA < amountAOwesV) {
                amountAOwesV -= amountVOwesA;
                amountVOwesA = 0;
            }
            else {
                Console.WriteLine("ERROR:  Invalid input for amounts that Andy owes Vince & vice versa.");
            }

            if (amountMOwesA >= amountAOwesM) {
                amountMOwesA -= amountAOwesM;
                amountAOwesM = 0;
            }
            else if (amountMOwesA < amountAOwesM) {
                amountAOwesM -= amountMOwesA;
                amountMOwesA = 0;
            }
            else {
                Console.WriteLine("ERROR:  Invalid input for amounts that Andy owes Mike & vice versa.");
            }

            if (amountMOwesV >= amountVOwesM) {
                amountMOwesV -= amountVOwesM;
                amountVOwesM = 0;
            }
            else if (amountMOwesV < amountVOwesM) {
                amountVOwesM -= amountMOwesV;
                amountMOwesV = 0;
            }
            else {
                Console.WriteLine("ERROR:  Invalid input for amounts that Vince owes Mike & vice versa.");
            }

            WriteNumberToLabel(vOwesA, amountVOwesA);
            WriteNumberToLabel(mOwesA, amountMOwesA);
            WriteNumberToLabel(aOwesV, amountAOwesV);
            WriteNumberToLabel(mOwesV, amountMOwesV);
            WriteNumberToLabel(aOwesM, amountAOwesM);
            WriteNumberToLabel(vOwesM, amountVOwesM);
        }
コード例 #2
0
 public void editReceiptEntry(List receiptList, int receiptNumber)
 {
     Receipt receipt = this.getReceiptEntry(receiptList.returnListOwner(), receiptNumber);
     receiptList.editReceipt(receipt, receiptNumber);
 }
コード例 #3
0
        public List<string> writeAllReceiptsToFile()
        {
            List<string> receiptListOutput = new List<string>();
            receiptListOutput.Add(Environment.NewLine);
            receiptListOutput.Add(String.Format("The following are the receipts contained within the {0} List:", listOwner));
            receiptListOutput.Add("==============================================================");

                foreach (Receipt receipt in receiptList) {
                    receiptListOutput.Add(Environment.NewLine);
                    receiptListOutput.Add(String.Format("Receipt {0}{1}:", receipt.returnReceiptName(), receipt.returnReceiptNumber()));
                    receiptListOutput.Add("--------------");
                    receiptListOutput.Add(String.Format("Communal Total = {0}", receipt.returnCommunalTotal()));
                    receiptListOutput.Add(String.Format("Communal Total Per Person = {0}", receipt.returnCommunalTotal() / 3));
                    if (receipt.returnATotal() != 0) {
                        receiptListOutput.Add(String.Format("Additional Amount Owed By Andy = {0}", receipt.returnATotal()));
                    }
                    if (receipt.returnVTotal() != 0) {
                        receiptListOutput.Add(String.Format("Additional Amount Owed By Vince = {0}", receipt.returnVTotal()));
                    }
                    if (receipt.returnMTotal() != 0) {
                        receiptListOutput.Add(String.Format("Additional Amount Owed By Mike = {0}", receipt.returnMTotal()));
                    }
                }
            return receiptListOutput;
        }
コード例 #4
0
 internal void outputReceipts(List userList)
 {
     finalOutputList.AddRange(userList.writeAllReceiptsToFile());
 }
コード例 #5
0
 internal void outputListTotals(List userList)
 {
     finalOutputList.Add(Environment.NewLine);
     finalOutputList.Add(String.Format("Final Totals For All Receipts On {0} List:", userList.returnListOwner()));
     finalOutputList.Add("----------------------------------");
     finalOutputList.Add(String.Format("Communal Total Of ALL Receipts On {0} List = {1}", userList.returnListOwner(), userList.returnCommunalTotal()));
     finalOutputList.Add(String.Format("Communal Total Owed Per Person Of ALL Receipts On {0} List = {1}", userList.returnListOwner(), userList.returnCommunalTotalPerPerson()));
     finalOutputList.Add(String.Format("Additional Total Amount Owed By Andy On {0} List = {1}", userList.returnListOwner(), userList.returnAListTotal()));
     finalOutputList.Add(String.Format("Additional Total Amount Owed By Vince On {0} List = {1}", userList.returnListOwner(), userList.returnVListTotal()));
     finalOutputList.Add(String.Format("Additional Total Amount Owed By Mike On {0} List = {1}", userList.returnListOwner(), userList.returnMListTotal()));
 }