/// <summary> /// Imports a text file and parses it into the parking class /// </summary> /// <param name="filePath"></param> public void ImportFromFile(string filePath) { for (int i = 0; i < squares.Length; i++) { squares[i] = new ParkingSquare(); } StreamReader sr; try { using (sr = new StreamReader(filePath)) { string line = string.Empty; while ((line = sr.ReadLine()) != null) { string[] values = line.Split(' '); //index, Type, RegNr, entryTime if (values[2] == "CAR") { string dateTime = values[6] + " " + values[7]; squares[int.Parse(values[0])].Add(new Car(values[4], DateTime.Parse(dateTime))); } else if (values[2] == "MC") { string dateTime = values[6] + " " + values[7]; squares[int.Parse(values[0])].Add(new Motorcycle(values[4], DateTime.Parse(dateTime))); } } } } catch (Exception) { } }
public Parking(int squareAmount) { squares = new ParkingSquare[squareAmount]; for (int i = 0; i < squareAmount; i++) { squares[i] = new ParkingSquare(); } }
public Parking() { squares = new ParkingSquare[100]; for (int i = 0; i < 100; i++) { squares[i] = new ParkingSquare(); } }