예제 #1
0
        /// <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)
            {
            }
        }
예제 #2
0
 public Parking(int squareAmount)
 {
     squares = new ParkingSquare[squareAmount];
     for (int i = 0; i < squareAmount; i++)
     {
         squares[i] = new ParkingSquare();
     }
 }
예제 #3
0
 public Parking()
 {
     squares = new ParkingSquare[100];
     for (int i = 0; i < 100; i++)
     {
         squares[i] = new ParkingSquare();
     }
 }