private void DisplayAllSlots(ParkingLot parkingLot) { List <ParkingSlot> parkingSlotList = parkingLot.GetParkingSlotList(); foreach (ParkingSlot slot in parkingSlotList) { Console.WriteLine("Slot No : {0}\tVehilce type : {1}\tVehicle No : {2}\tBooked : {3}", slot.SlotId, slot.vehicle.vehicleType, slot.vehicle.VehicleNumber, slot.IsBooked); } }
private void DisplaySlots(ParkingLot parkingLot, bool v) { IEnumerable <ParkingSlot> slotList = parkingLot.GetParkingSlotList().Where(e => e.IsBooked == v); foreach (ParkingSlot slot in slotList) { Console.WriteLine("Slot No : {0}\tVehilce type : {1}\tVehicle No : {2}\tBooked : {3}", slot.SlotId, slot.vehicle.vehicleType, slot.vehicle.VehicleNumber, slot.IsBooked); } }
public void DisplayAllSlots(ParkingLot parkingLot) { Console.WriteLine("\n\n****************** Parking Alloment Display ******************"); Console.WriteLine("Two Wheeler Parking Empty Slots = " + (TwoWheelerCapacity - parkingLot.GetNumberOfTwoWheelerParked())); Console.WriteLine("Four Wheeler Parking Empty Slots = " + (FourWheelerCapacity - parkingLot.GetNumberOfFourWheelerParked())); Console.WriteLine("Other Vehicle Parking Empty Slots = " + (OtherVehicleCapacity - parkingLot.GetNumberOfOtherVehicleParked())); List <ParkingSlot> slotList = parkingLot.GetParkingSlotList(); foreach (ParkingSlot slot in slotList) { Console.WriteLine("***** Slot Number : {0} *****", slot.GetSlotId()); Console.WriteLine("\nVehicleType {0}\t\tVehicle no. {1} ", slot.GetVehicle().GetVehicleType(), slot.GetVehicle().GetVehicleNumber()); } Console.WriteLine("\n\n"); }
public void DisplayAllSlots(ParkingLot parkingLot) { Console.WriteLine("\n\n****************** Parking Alloment Display ******************"); List <ParkingSlot> slotList = parkingLot.GetParkingSlotList(); Console.WriteLine("Two Wheeler Parking Empty Slots = " + (TwoWheelerCapacity - slotList.Where(e => e.vehicle.vehicleType == VehicleType.TWO_WHEELER).Count())); Console.WriteLine("Four Wheeler Parking Empty Slots = " + (FourWheelerCapacity - slotList.Where(e => e.vehicle.vehicleType == VehicleType.FOUR_WHEELER).Count())); Console.WriteLine("Other Vehicle Parking Empty Slots = " + (OtherVehicleCapacity - slotList.Where(e => e.vehicle.vehicleType == VehicleType.OTHER).Count())); foreach (ParkingSlot slot in slotList) { Console.WriteLine("\n***** Slot Number : {0} *****", slot.SlotId); Console.WriteLine("VehicleType {0}\t\tVehicle no. {1} ", slot.vehicle.vehicleType, slot.vehicle.VehicleNumber); Console.WriteLine("Ticket No: {0}\t\tIn-Time: {1}\t\tOut-Time: {2}", slot.ticket.TicketNumber, slot.ticket.InTime, slot.ticket.OutTime); } Console.WriteLine("\n\n"); }
public void MainMenu(ParkingLot parkingLot) { while (true) { Console.WriteLine("\n\n1. Park Vehicle"); Console.WriteLine("2. Unpark Vehicle"); Console.WriteLine("3. Display All Slots"); Console.WriteLine("4. Exit"); Console.WriteLine("Choose any option"); string choice = Console.ReadLine(); if (choice == "4") { break; } VehicleType vehicleType; ParkingSlot parkingSlot; switch (int.Parse(choice)) { case 1: // add vehicle parkingSlot = ReadVehicleDetail(out vehicleType); while (vehicleType == VehicleType.NONE) { parkingSlot = ReadVehicleDetail(out vehicleType); } if (parkingLot.GetParkingSlotList().Where(e => e.vehicle.vehicleType == VehicleType.TWO_WHEELER).Count() < TwoWheelerCapacity && parkingLot.GetParkingSlotList().Where(e => e.vehicle.vehicleType == VehicleType.FOUR_WHEELER).Count() < FourWheelerCapacity && parkingLot.GetParkingSlotList().Where(e => e.vehicle.vehicleType == VehicleType.OTHER).Count() < OtherVehicleCapacity) { parkingLot.ParkVehicle(parkingSlot); } else { Error(SLOT_FULL_ERROR); } break; case 2: // remove vehicle parkingSlot = ReadVehicleDetail(out vehicleType); bool unParked = false; while (vehicleType == VehicleType.NONE) { parkingSlot = ReadVehicleDetail(out vehicleType); } List <ParkingSlot> slotList = parkingLot.GetParkingSlotList(); foreach (ParkingSlot slot in slotList) { if (slot.vehicle.vehicleType == vehicleType && slot.vehicle.VehicleNumber == parkingSlot.vehicle.VehicleNumber) { parkingLot.UnParkVehicle(slot); slot.ticket.OutTime = DateTime.Now; unParked = true; } } if (!unParked) { Error(VEHICLE_NOT_FOUND_ERROR); } break; case 3: DisplayAllSlots(parkingLot); break; default: Console.WriteLine("Invalid Choice"); break; } } }