public void AddFreeParkSpot(Spot spot) { this.freeParkSpots.Add(spot); }
private static void ReadInput() { var numOfParkZones = int.Parse(Console.ReadLine()); parkZones = new List <ParkZone>(); var parkZoneParams = new List <string>(); for (int i = 0; i < numOfParkZones; i++) { parkZoneParams.Add(Console.ReadLine()); } var freeParkSpots = Console.ReadLine() .Split(';') .ToArray(); var targetCoord = Console.ReadLine() .Split(", ".ToArray(), StringSplitOptions.RemoveEmptyEntries) .Select(int.Parse) .ToArray(); var target = new Spot(targetCoord[0], targetCoord[1]); var timePerSpot = int.Parse(Console.ReadLine()); for (int i = 0; i < parkZoneParams.Count; i++) { var line = parkZoneParams[i].Split(':').ToArray(); var parkZoneName = line[0].Trim(); var parameters = line[1] .Trim() .Split(", ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries) .ToArray(); var coordinates = parameters.Take(4).Select(int.Parse).ToArray(); var price = decimal.Parse(parameters[4]); var parkZone = new ParkZone(parkZoneName, coordinates[0], coordinates[1], coordinates[2], coordinates[3], price, target, timePerSpot); parkZones.Add(parkZone); } foreach (var parkSpotStr in freeParkSpots) { var parkSpotCoord = parkSpotStr .Split(", ".ToArray(), StringSplitOptions.RemoveEmptyEntries) .Select(int.Parse) .ToArray(); var x = parkSpotCoord[0]; var y = parkSpotCoord[1]; foreach (var parkZone in parkZones) { if (parkZone.isInParkZone(x, y)) { var parkSpot = new Spot(x, y, parkZone); break; } } } }
public ParkZone(string name, int x, int y, int width, int hight, decimal price, Spot target, int timePerSpotInSec) { Name = name; X = x; Y = y; Width = width; Hight = hight; Price = price; TimePerSpotInSec = timePerSpotInSec; Target = target; freeParkSpots = new List <Spot>(); }