repl.it
@big_deelan/

2020 NEA

Python

Skeleton Code

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
#Skeleton Program code for the AQA A Level Paper 1 Summer 2020 examination
#this code should be used in conjunction with the Preliminary Material
#written by the AQA Programmer Team
#developed in the Python 3.5.1 programming environment

import math # Use this only for square root
import random # For random number gen


# This class represents Households
class Household:
  _NextID = 1

  def __init__(self, X, Y): # Constructor - initialises all of the objects variables
    self._XCoord = X
    self._YCoord = Y
    self._ChanceEatOutPerDay = random.random() # Set chance of eating out to be a float between 0 and 1
    self._ID = Household._NextID 
    Household._NextID += 1 # Rolling ID this incvreases by 1 every time we make a Household

  # Returns all of the details (data) in the form of a long string
  def GetDetails(self):
    Details = str(self._ID) + "     Coordinates: (" + str(self._XCoord) + ", " + str(self._YCoord) + ")     Eat out probability: " + str(self._ChanceEatOutPerDay)
    return Details

  # Returns the probabilty that a Household will eat out on any given day
  def GetChanceEatOut(self):
    return self._ChanceEatOutPerDay

  # Return X coord
  def GetX(self):
    return self._XCoord

  # Get Y coord
  def GetY(self):
    return self._YCoord

# A Class to represent a collection of Households
class Settlement:
  
  # Initailise all the data - default to 1000 by 1000 with 250 Households
  def __init__(self):
    self._XSize = 1000
    self._YSize = 1000
    self._StartNoOfHouseholds = 250
    self._Households = [] # Empty list of Households
    self._CreateHouseholds()
 
  # Access the number of households
  def GetNumberOfHouseholds(self):
    return len(self._Households)

  # Access the X Size
  def GetXSize(self):
    return self._XSize

  # Access the Y size
  def GetYSize(self):
    return self._YSize

  #Return a random X and Y Location
  def GetRandomLocation(self):
    X = random.randint(0, self._XSize - 1)
    Y = random.randint(0, self._YSize - 1)
    return X, Y

  # Creates as many households as the StartNoOfHouseholds variable
  def _CreateHouseholds(self):
    for Count in range (0, self._StartNoOfHouseholds):
      self.AddHousehold()

  # Adds a houseghold ina  random location to the list
  def AddHousehold(self):
    X, Y = self.GetRandomLocation()
    Temp = Household(X, Y)
    self._Households.append(Temp)

  # Loop through our list of Households and display all of their details
  def DisplayHouseholds(self):
    print("\n**********************************")
    print("*** Details of all households: ***")
    print("**********************************\n")
    for H in self._Households:
      print(H.GetDetails())
    print()

  # Get a random number , test to see if the given Household has a higher chance of eating out than it
  # If so return True and the coordinates
  def FindOutifHouseholdEatsOut(self, HouseholdNo):
    EatOutRNo = random.random() # Random number between 0 and 1
    X = self._Households[HouseholdNo].GetX()
    Y = self._Households[HouseholdNo].GetY()
    if EatOutRNo < self._Households[HouseholdNo].GetChanceEatOut():
      return True, X, Y # This household at these coords eats out today
    else:
      return False, X, Y # This household at these coords does not eat out today

# This is a subclass of Settlement
class LargeSettlement(Settlement):
  def __init__(self, ExtraXSize, ExtraYSize, ExtraHouseholds):
    super(LargeSettlement, self).__init__()
    self._XSize += ExtraXSize
    self._YSize += ExtraYSize
    self._StartNoOfHouseholds += ExtraHouseholds
    for Count in range (1, ExtraHouseholds + 1):
      self.AddHousehold()

class SmallSettlement(Settlement):
  def __init__(self, ExtraXSize, ExtraYSize, ExtraHouseholds):
    super(LargeSettlement, self).__init__()
    self._XSize -= ExtraXSize
    self._YSize -= ExtraYSize
    self._StartNoOfHouseholds -= MinusHouseholds
    for Count in range (1, MinusHouseholds - 1):
      self.RemoveHousehold()

# This represents the Food outlets, we pass it X coord, Y coord and Max capacity
class Outlet:
  def __init__(self, XCoord, YCoord, MaxCapacityBase):
    self._XCoord = XCoord
    self._YCoord = YCoord
    self._Capacity = int(MaxCapacityBase * 0.6)
    self._MaxCapacity = MaxCapacityBase + random.randint(0, 49) - random.randint(0, 49) # Add some random to the max capacity
    self._DailyCosts = MaxCapacityBase * 0.2 + self._Capacity * 0.5 + 100
    self.NewDay()

  # Data access
  def GetCapacity(self):
    return self._Capacity

  # data access
  def GetX(self):
    return self._XCoord

  # data access
  def GetY(self):
    return self._YCoord

  # Allows us to alter the daily costs
  def AlterDailyCost(self, Amount):
    self._DailyCosts += Amount

  # Alter the capacity, check to see greater than 0 or less than max
  def AlterCapacity(self, Change):
    OldCapacity = self._Capacity
    self._Capacity += Change
    if self._Capacity > self._MaxCapacity:
      self._Capacity = self._MaxCapacity
      return self._MaxCapacity - OldCapacity
    elif self._Capacity < 0:
      self._Capacity = 0
    self._DailyCosts = self._MaxCapacity * 0.2 + self._Capacity * 0.5 + 100
    return Change

  # This just increases the count of how many people have visited
  def IncrementVisits(self):
    self._VisitsToday += 1

  # Resets the visit counter to 0     
  def NewDay(self):
    self._VisitsToday = 0

  # Calculate the profit by no of visits times profit per meal take away daily cost
  def CalculateDailyProfitLoss(self, AvgCostPerMeal, AvgPricePerMeal):
    return (AvgPricePerMeal - AvgCostPerMeal) * self._VisitsToday - self._DailyCosts

  # Get all of the restaurant details in a long string
  def GetDetails(self):
    Details = "Coordinates: (" + str(self._XCoord) + ", " + str(self._YCoord) + ")     Capacity: " + str(self._Capacity) + "      Maximum Capacity: "
    Details += str(self._MaxCapacity) + "      Daily Costs: " + str(self._DailyCosts) + "      Visits today: " + str(self._VisitsToday)
    return Details


# A Class to represent the companies
class Company:

  # Constructor
  def __init__(self, Name, Category, Balance, X, Y, FuelCostPerUnit, BaseCostOfDelivery):
    self._Outlets = []
    self._FamilyOutletCost = 1000
    self._FastFoodOutletCost = 2000
    self._NamedChefOutletCost = 15000
    self._FamilyFoodOutletCapacity = 150
    self._FastFoodOutletCapacity = 200        
    self._NamedChefOutletCapacity = 50
    self._Name = Name
    self._Category = Category
    self._Balance = Balance
    self._FuelCostPerUnit = FuelCostPerUnit
    self._BaseCostOfDelivery = BaseCostOfDelivery
    self._ReputationScore = 100
    self._DailyCosts = 100
    # Add some random element to the reputation score based on the category
    if self._Category == "fast food":
      self._AvgCostPerMeal = 5
      self._AvgPricePerMeal = 10
      self._ReputationScore += random.random() * 10 - 8
    elif self._Category == "family":
      self._AvgCostPerMeal = 12
      self._AvgPricePerMeal = 14
      self._ReputationScore += random.random() * 30 - 5
    else:
      self._AvgCostPerMeal = 20
      self._AvgPricePerMeal = 40
      self._ReputationScore += random.random() * 50
    # Create the first outlet for your company at the given X Y coords
    self.OpenOutlet(X, Y)

  # Data access functions
  def GetName(self):
    return self._Name

  def GetNumberOfOutlets(self):
    return len(self._Outlets)

  def GetReputationScore(self):
    return self._ReputationScore

  # Modify the data held
  def AlterDailyCosts(self, Change):
    self._DailyCosts += Change

  def AlterAvgCostPerMeal(self, Change):
    self._AvgCostPerMeal += Change
        
  def AlterFuelCostPerUnit(self, Change):
    self._FuelCostPerUnit += Change

  def AlterReputation(self, Change):
    self._ReputationScore += Change

  # This function goes through all of the companies outlets and resets the visitor numbers
  def NewDay(self):
    for O in self._Outlets:
      O.NewDay()

  # This function          
  def AddVisitToNearestOutlet(self, X, Y):
    # Set the outlet counter to 0
    NearestOutlet = 0
    # Find the x and y coordinate distance between Outlet 0 and the Household
    NearestOutletDistance = math.sqrt((self._Outlets[0].GetX() - X) ** 2 + (self._Outlets[0].GetY() - Y) ** 2)
    # Go through the list of outlets starting at position 1 
    for Current in range (1, len(self._Outlets)):
      # Find the distance for ewach outlet
      CurrentDistance = math.sqrt((self._Outlets[Current].GetX() - X) ** 2 + (self._Outlets[Current].GetY() - Y) ** 2)
      # If the current Outlet is closer than the the nearest, set it to be the nearest
      if CurrentDistance < NearestOutletDistance:
        NearestOutletDistance = CurrentDistance
        NearestOutlet = Current
    # Once we have looped through all of them...abs
    # Add a visitor to the nearest
    self._Outlets[NearestOutlet].IncrementVisits()

  # Form a long string with the company details and then loop through all of the companies outlets and display their details
  def GetDetails(self):
    Details = ""
    Details += "Name: " + self._Name + "\nType of business: " + self._Category + "\n"
    Details += "Current balance: " + str(self._Balance) + "\nAverage cost per meal: " + str(self._AvgCostPerMeal) + "\n"
    Details += "Average price per meal: " + str(self._AvgPricePerMeal) + "\nDaily costs: " + str(self._DailyCosts) + "\n"
    Details += "Delivery costs: " + str(self.CalculateDeliveryCost()) + "\nReputation: " + str(self._ReputationScore) + "\n\n"
    Details += "Number of outlets: " + str(len(self._Outlets)) + "\nOutlets\n"
    for Current in range (1, len(self._Outlets) + 1):
      Details += str(Current) + ". " + self._Outlets[Current - 1].GetDetails() + "\n"
    return Details


  # This function calculates new balances at the end of each day
  def ProcessDayEnd(self):
    Details = ""
    ProfitLossFromOutlets = 0
    ProfitLossFromThisOutlet = 0
    # If we have more than one outlet, we need to calculate delivery costs
    if len(self._Outlets) > 1:
      DeliveryCosts = self._BaseCostOfDelivery + self.CalculateDeliveryCost()
    else:
      DeliveryCosts = self._BaseCostOfDelivery
    Details += "Daily costs for company: " + str(self._DailyCosts) + "\nCost for delivering produce to outlets: " + str(DeliveryCosts) + "\n"
    # For each outlet... Calculate the profit or loss
    for Current in range (0, len(self._Outlets)):
      ProfitLossFromThisOutlet = self._Outlets[Current].CalculateDailyProfitLoss(self._AvgCostPerMeal, self._AvgPricePerMeal)
      Details += "Outlet " + str(Current + 1) + " profit/loss: " + str(ProfitLossFromThisOutlet) + "\n"
      # Add individual outlet profits to the total
      ProfitLossFromOutlets += ProfitLossFromThisOutlet
    Details += "Previous balance for company: " + str(self._Balance) + "\n"
    # Update the company balance
    self._Balance += ProfitLossFromOutlets - self._DailyCosts - DeliveryCosts
    Details += "New balance for company: " + str(self._Balance)
    return Details
      
  def CloseOutlet(self, ID):
    CloseCompany = False
    del(self._Outlets[ID])
    if len(self._Outlets) == 0:
      CloseCompany = True
    return CloseCompany
      
  def ExpandOutlet(self, ID):
    Change = int(input("Enter amount you would like to expand the capacity by: "))
    Result = self._Outlets[ID].AlterCapacity(Change)
    if Result == Change:
      print("Capacity adjusted.")
    else:
      print("Only some of that capacity added, outlet now at maximum capacity.")
        
  # Call this to add an outlet to the company
  def OpenOutlet(self, X, Y):
    # Remove the cost of an outlet from the company balance
    if self._Category == "fast food":
      self._Balance -= self._FastFoodOutletCost
      self._Capacity = self._FastFoodOutletCapacity
    elif self._Category == "family":
      self._Balance -= self._FamilyOutletCost
      self._Capacity = self._FamilyFoodOutletCapacity
    else:
      self._Balance -= self._NamedChefOutletCost
      self._Capacity = self._NamedChefOutletCapacity
    # Create the actual Outlet
    NewOutlet = Outlet(X, Y, self._Capacity)
    # Add the outlet to the companies list of outlets
    self._Outlets.append(NewOutlet)


  # Get a list of the companies outlets (as a list of numbers)      
  def __GetListOfOutlets(self):
    Temp = []
    for Current in range (0, len(self._Outlets)):
      Temp.append(Current)
    return Temp

  # Returns the distance between the two outlets
  def __GetDistanceBetweenTwoOutlets(self, Outlet1, Outlet2):
    return math.sqrt((self._Outlets[Outlet1].GetX() - self._Outlets[Outlet2].GetX()) ** 2 + (self._Outlets[Outlet1].GetY() - self._Outlets[Outlet2].GetY()) ** 2)

  
  def CalculateDeliveryCost(self):
    ListOfOutlets = self.__GetListOfOutlets()
    TotalDistance = 0.0
    for Current in range (0, len(ListOfOutlets) - 1):
      TotalDistance += self.__GetDistanceBetweenTwoOutlets(ListOfOutlets[Current], ListOfOutlets[Current + 1])
    TotalCost = TotalDistance * self._FuelCostPerUnit
    return TotalCost

class Simulation:
  def __init__(self):
    self._Companies = []
    self._FuelCostPerUnit = 0.0098
    self._BaseCostforDelivery = 100
    Choice = input("Enter L for a large settlement, S for a small settlement, anything else for a normal size settlement: ")
    if Choice == "L":
      ExtraX = int(input("Enter additional amount to add to X size of settlement: "))
      ExtraY = int(input("Enter additional amount to add to Y size of settlement: "))
      ExtraHouseholds = int(input("Enter additional number of households to add to settlement: "))
      self._SimulationSettlement = LargeSettlement(ExtraX, ExtraY, ExtraHouseholds)
    elif Choice == "S":
      MinusX = int(input("Enter amount to take away from X size of settlement: "))
      MinusY = int(input("Enter amount to take away from Y size of settlement: "))
      MinusHouselholds = int(input("Enter households to remove from the settlement: "))
      self._SimulationSettlement = SmallSettlement(MinusX, MinusY, MinusHouseholds)
    else:
      self._SimulationSettlement = Settlement()            
    Choice = input("Enter D for default companies, anything else to add your own start companies: ")
    if Choice == "D":
      self._NoOfCompanies = 3
      Company1 = Company("AQA Burgers", "fast food", 100000, 200, 203, self._FuelCostPerUnit, self._BaseCostforDelivery)
      self._Companies.append(Company1)
      self._Companies[0].OpenOutlet(300, 987)
      self._Companies[0].OpenOutlet(500, 500)
      self._Companies[0].OpenOutlet(305, 303)
      self._Companies[0].OpenOutlet(874, 456)
      self._Companies[0].OpenOutlet(23, 408)
      self._Companies[0].OpenOutlet(412, 318)
      Company2 = Company("Ben Thor Cuisine", "named chef", 100400, 390, 800, self._FuelCostPerUnit, self._BaseCostforDelivery)
      self._Companies.append(Company2)
      Company3 = Company("Paltry Poultry", "fast food", 25000, 800, 390, self._FuelCostPerUnit, self._BaseCostforDelivery)
      self._Companies.append(Company3)
      self._Companies[2].OpenOutlet(400, 390)
      self._Companies[2].OpenOutlet(820, 370)
      self._Companies[2].OpenOutlet(800, 600)
    else:
      self._NoOfCompanies = int(input("Enter number of companies that exist at start of simulation: "))
      for Count in range (1, self._NoOfCompanies + 1):
        self.AddCompany()
            
  def DisplayMenu(self):
    print("\n*********************************")
    print("**********    MENU     **********")
    print("*********************************")
    print("1. Display details of households")
    print("2. Display details of companies")
    print("3. Modify company")
    print("4. Add new company")
    print("6. Advance to next day")
    print("Q. Quit")
    print("\nEnter your choice: ", end = "")

  def __DisplayCompaniesAtDayEnd(self):
    print("\n**********************")
    print("***** Companies: *****")
    print("**********************\n")
    for C in self._Companies:
      print(C.GetName())
      print()
      Details = C.ProcessDayEnd()
      print(Details + "\n")

  def __ProcessAddHouseholdsEvent(self):
    NoOfNewHouseholds = random.randint(1, 4)
    for Count in range(1, NoOfNewHouseholds + 1):
      self._SimulationSettlement.AddHousehold()
    print(str(NoOfNewHouseholds) + " new households have been added to the settlement.")
        
  def __ProcessCostOfFuelChangeEvent(self):
    FuelCostChange = random.randint(1, 9) / 10.0
    UpOrDown = random.randint(0, 1)
    CompanyNo = random.randint(0, len(self._Companies) - 1)
    if UpOrDown == 0:
      print("The cost of fuel has gone up by " + str(FuelCostChange) + " for " + self._Companies[CompanyNo].GetName())
    else:
      print("The cost of fuel has gone down by " + str(FuelCostChange) + " for " + self._Companies[CompanyNo].GetName())
      FuelCostChange *= -1
    self._Companies[CompanyNo].AlterFuelCostPerUnit(FuelCostChange)
        
  def __ProcessReputationChangeEvent(self):
    ReputationChange = random.randint(1, 9) / 10.0
    UpOrDown = random.randint(0, 1)
    CompanyNo = random.randint(0, len(self._Companies) - 1)
    if UpOrDown == 0:
      print("The reputation of " + self._Companies[CompanyNo].GetName() + " has gone up by " + str(ReputationChange))
    else:
      print("The reputation of " + self._Companies[CompanyNo].GetName() + " has gone down by " + str(ReputationChange))
      ReputationChange *= -1
    self._Companies[CompanyNo].AlterReputation(ReputationChange)
        
  def __ProcessCostChangeEvent(self):
    CostToChange = random.randint(0, 1)
    UpOrDown = random.randint(0, 1)
    CompanyNo = random.randint(0, len(self._Companies) - 1)
    AmountOfChange = 0.0
    if CostToChange == 0:
      AmountOfChange = random.randint(1, 19) / 10.0
      if UpOrDown == 0:
        print("The daily costs for " + self._Companies[CompanyNo].GetName() + " have gone up by " + str(AmountOfChange))
      else:
        print("The daily costs for " + self._Companies[CompanyNo].GetName() + " have gone down by " + str(AmountOfChange))
        AmountOfChange *= -1
      self._Companies[CompanyNo].AlterDailyCosts(AmountOfChange)
    else:
      AmountOfChange = random.randint(1, 9) / 10.0
      if UpOrDown == 0:
        print("The average cost of a meal for " + self._Companies[CompanyNo].GetName() + " has gone up by " + str(AmountOfChange))
      else:
        print("The average cost of a meal for " + self._Companies[CompanyNo].GetName() + " has gone down by " + str(AmountOfChange))
        AmountOfChange *= -1
      self._Companies[CompanyNo].AlterAvgCostPerMeal(AmountOfChange)
        
  def __DisplayEventsAtDayEnd(self):
    print("\n***********************")
    print("*****   Events:   *****")
    print("***********************\n")
    EventRanNo = random.random()
    if EventRanNo < 0.25:
      EventRanNo = random.random()
      if EventRanNo < 0.25:
        self.__ProcessAddHouseholdsEvent()
      EventRanNo = random.random()
      if EventRanNo < 0.5:
        self.__ProcessCostOfFuelChangeEvent()
      EventRanNo = random.random()
      if EventRanNo < 0.5 :
        self.__ProcessReputationChangeEvent()
      EventRanNo = random.random()
      if EventRanNo >= 0.5:
        self.__ProcessCostChangeEvent()
    else:
      print("No events.")

  def ProcessDayEnd(self):
    TotalReputation = 0.0
    Reputations = []
    for C in self._Companies:
      C.NewDay()
      TotalReputation += C.GetReputationScore()
      Reputations.append(TotalReputation)
    LoopMax = self._SimulationSettlement.GetNumberOfHouseholds() - 1
    for Counter in range (0, LoopMax + 1):
      EatsOut, X, Y = self._SimulationSettlement.FindOutifHouseholdEatsOut(Counter)
      if EatsOut:
        CompanyRNo = random.randint(1, int(TotalReputation))
        Current = 0
        while Current < len(Reputations):
          if CompanyRNo < Reputations[Current]:
            self._Companies[Current].AddVisitToNearestOutlet(X, Y)
            break
          Current += 1
    self.__DisplayCompaniesAtDayEnd()
    self.__DisplayEventsAtDayEnd()
        
  def AddCompany(self):
    CompanyName = input("Enter a name for the company: ")
    Balance = int(input("Enter the starting balance for the company: "))
    TypeOfCompany = ""
    while not(TypeOfCompany == "1" or TypeOfCompany == "2" or TypeOfCompany == "3"):
      TypeOfCompany = input("Enter 1 for a fast food company, 2 for a family company or 3 for a named chef company: ")
    if TypeOfCompany == "1":
      TypeOfCompany = "fast food"
    elif TypeOfCompany == "2":
      TypeOfCompany = "family"
    else:
      TypeOfCompany = "named chef"
    X, Y = self._SimulationSettlement.GetRandomLocation()
    NewCompany = Company(CompanyName, TypeOfCompany, Balance, X, Y, self._FuelCostPerUnit, self._BaseCostforDelivery)
    self._Companies.append(NewCompany)
        
  def GetIndexOfCompany(self, CompanyName):
    Index = -1
    for Current in range (0, len(self._Companies)):
      if self._Companies[Current].GetName().lower() == CompanyName.lower():
        return Current
    return Index

  def ModifyCompany(self, Index):
    print("\n*********************************")
    print("*******  MODIFY COMPANY   *******")
    print("*********************************")
    print("1. Open new outlet")
    print("2. Close outlet")
    print("3. Expand outlet")
    Choice = input("\nEnter your choice: ")
    print()
    if Choice == "2" or Choice == "3":
      OutletIndex = int(input("Enter ID of outlet: "))
      if OutletIndex > 0 and OutletIndex <= self._Companies[Index].GetNumberOfOutlets():
        if Choice == "2":
          CloseCompany = self._Companies[Index].CloseOutlet(OutletIndex - 1)
          if CloseCompany:
            print("That company has now closed down as it has no outlets.")
            del(self._Companies[Index])
        else:
          self._Companies[Index].ExpandOutlet(OutletIndex - 1)
      else:
          print("Invalid outlet ID.")
    elif Choice == "1":
      X = int(input("Enter X coordinate for new outlet: "))
      Y = int(input("Enter Y coordinate for new outlet: "))
      if X >= 0 and X < self._SimulationSettlement.GetXSize() and Y >= 0 and Y < self._SimulationSettlement.GetYSize():
        self._Companies[Index].OpenOutlet(X, Y)
      else:
        print("Invalid coordinates.")
    print()

  def DisplayCompanies(self):
    print("\n*********************************")
    print("*** Details of all companies: ***")
    print("*********************************\n")
    for C in self._Companies:
      print(C.GetDetails() + "\n")
    print()
        
  def Run(self):
    Choice = ""
    while Choice != "Q":
      self.DisplayMenu()
      Choice = input()
      if Choice == "1":
        self._SimulationSettlement.DisplayHouseholds()
      elif Choice == "2":
        self.DisplayCompanies()
      elif Choice == "3":
        Index = -1
        while Index == -1:
          CompanyName = input("Enter company name: ")
          Index = self.GetIndexOfCompany(CompanyName)
        self.ModifyCompany(Index)
      elif Choice == "4":
        self.AddCompany()
      elif Choice == "6":
        self.ProcessDayEnd()
      elif Choice == "Q":
        print("Simulation finished, press Enter to close.")
        input()

def Main():
  ThisSim = Simulation()
  ThisSim.Run()

Main()
Fetching token
?