2020 - Display net gain/loss for the companies

From TRCCompSci - AQA Computer Science
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);