Пример #1
0
        static void Main(string[] args)
        {
            Passengers x1 = new Passengers("John Doe", "Jane Doe");

            Passengers x2 = new Passengers("Mark Freeman", "Rose Freeman");

            Passengers x3 = new Passengers("Bob Smith", "Julia Smith");

            Car c1 = new Car("Black", "VW", "Jetta");
            // Console.WriteLine("c1 = {0}", c1.ToString());

            Car c2 = new Car("Blue", "Mazda", "3");
            // Console.WriteLine("c2 = {0}", c2.ToString());

            Car c3 = new Car("Yellow", "Cheverle", "Camaro");

            c1.seats(x1, 1);
            c2.seats(x2, 1);
            c3.seats(x3, 1);

            ParkingGarage p1 = new ParkingGarage(7);

            p1.parkCar(c1, 1);
            // p1.towCar(1);
            p1.parkCar(c2, 2);
            p1.parkCar(c3, 3);
        }
Пример #2
0
        public bool isSeatAvailable(int seatNumber)
        {
            Passengers thePeopleInTheSeats = availableSeats[seatNumber];

            if (availableSeats[seatNumber] == null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        public void seats(Passengers people, int seats)
        {
            bool isSeatEmpty = isSeatAvailable(seats);

            if (isSeatEmpty == true)
            {
                // bad parking garage did not actually park my car ....
                this.availableSeats[seats] = people;
            }
            else
            {
                throw new Exception("Slot " + seats + " is taken!");
            }
        }