2020 - Display net gain/loss for the companies

From TRCCompSci - AQA Computer Science
Revision as of 09:24, 11 December 2019 by Admin (talk | contribs) (Created page with "=The Issue= The balance for each company is displayed every turn, it prints the previous and the current balance. Profit / Loss is the difference between the two. =Solution=...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Issue

The balance for each company is displayed every turn, it prints the previous and the current balance. Profit / Loss is the difference between the two.

Solution

Add an output to display the Profit / Loss for the company

Example

Find the 'ProcessDayEnd' method in the Company class, look for the final lines in this method:

            details += "Previous balance for company: " + balance.ToString() + "\n";
            balance += profitLossFromOutlets - dailyCosts - deliveryCosts;
            details += "New balance for company: " + balance.ToString();
            return details;

We need to add more to 'details', so add the following line before the 'return details;' line:

            details += "Profit / Loss for company: " + (profitLossFromOutlets - dailyCosts - deliveryCosts);