Difference between revisions of "2020 - Option 5 is missing, it could be to remove a company"
(Created page with "=ModifyCompany method in Simulation= Look for the ModifyCompany method within the Simulation class. Look for this section of the ModifyCompany method: <syntaxhighlight lang=...") |
|||
Line 1: | Line 1: | ||
+ | =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. | ||
+ | |||
+ | |||
=ModifyCompany method in Simulation= | =ModifyCompany method in Simulation= | ||
Look for the ModifyCompany method within the Simulation class. | Look for the ModifyCompany method within the Simulation class. | ||
Line 29: | Line 33: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | The line 'companies.RemoveAt(index)' actually removes a company. So copy this line and create the new method below: | |
<syntaxhighlight lang=chsarp> | <syntaxhighlight lang=chsarp> | ||
Line 39: | Line 43: | ||
Paste the copied code into this empty method. | 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 |
Revision as of 14:02, 18 December 2019
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.
ModifyCompany method in Simulation
Look for the ModifyCompany method within the Simulation class.
Look for this section of the ModifyCompany method:
Console.Write("Enter ID of outlet: ");
outletIndex = Convert.ToInt32(Console.ReadLine());
if (outletIndex > 0 && outletIndex <= companies[index].GetNumberOfOutlets())
{
if (choice == "2")
{
closeCompany = companies[index].CloseOutlet(outletIndex - 1);
if (closeCompany)
{
Console.WriteLine("That company has now closed down as it has no outlets.");
companies.RemoveAt(index);
}
}
else
{
companies[index].ExpandOutlet(outletIndex - 1);
}
}
else
{
Console.WriteLine("Invalid outlet ID.");
}
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