Difference between revisions of "2020 - Option 5 is missing, it could be to remove a company"
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=Look at the Run method in the Simulation class= | =Look at the Run method in the Simulation class= | ||
− | option 3 is to modify a company, so copy this case statement and change it to use 5 instead. | + | option 3 is to modify a company, so copy and paste this case statement and change it to use 5 instead. |
− | |||
=ModifyCompany method in Simulation= | =ModifyCompany method in Simulation= | ||
Line 8: | Line 7: | ||
Look for this section of the ModifyCompany method: | Look for this section of the ModifyCompany method: | ||
− | <syntaxhighlight lang= | + | <syntaxhighlight lang=csharp> |
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
closeCompany = companies[index].CloseOutlet(outletIndex - 1); | closeCompany = companies[index].CloseOutlet(outletIndex - 1); | ||
if (closeCompany) | if (closeCompany) | ||
Line 21: | Line 15: | ||
companies.RemoveAt(index); | companies.RemoveAt(index); | ||
} | } | ||
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
The line 'companies.RemoveAt(index)' actually removes a company. So copy this line and create the new method below: | The line 'companies.RemoveAt(index)' actually removes a company. So copy this line and create the new method below: | ||
− | <syntaxhighlight lang= | + | <syntaxhighlight lang=csharp> |
public void RemoveComapny(int index) | public void RemoveComapny(int index) | ||
{ | { |
Latest revision as of 14:06, 18 December 2019
Look at the Run method in the Simulation class
option 3 is to modify a company, so copy and paste this case statement and change it to use 5 instead.
ModifyCompany method in Simulation
Look for the ModifyCompany method within the Simulation class.
Look for this section of the ModifyCompany method:
closeCompany = companies[index].CloseOutlet(outletIndex - 1);
if (closeCompany)
{
Console.WriteLine("That company has now closed down as it has no outlets.");
companies.RemoveAt(index);
}
The line 'companies.RemoveAt(index)' actually removes a company. So copy this line and create the new method below:
public void RemoveComapny(int index)
{
}
Paste the copied code into this empty method.
Go back to the Run method in Simulation
You new case 5 can now run RemoveCompany(index) instead