public override object Clone() { Load load = new Load(Weight, Price, IsEncoded, IsToxic); SpoiledLoad spoiledLoad = new SpoiledLoad(load); return(spoiledLoad); }
private void FillLoadsPosition() { if (Height * Width > 10) { int loadNumber = Height * Width / 5; Random random = new Random(); for (int i = 0; i < loadNumber; i++) { int x = random.Next(1, Width - 1); int y = random.Next(1, Height - 1); double weight = random.Next(1, 1000); double price = random.Next(1, 1000); bool isRegular = random.Next(1, 100) <= 75; Load load; if (isRegular) { load = new Load(weight, price, false, false); } else { bool isEcoded = random.Next(1, 100) <= 40; bool isToxic = random.Next(1, 100) <= 10; load = new Load(weight, price, isEcoded, isToxic); if (random.Next(1, 100) <= 20) { load = new SpoiledLoad(load); } } if (!LoadsPosition.ContainsKey(new Coordinates(x, y)) && PlayerCurrentCoordinates != new Coordinates(x, y)) { LoadsPosition.Add(new Coordinates(x, y), load); } } } }