public void InitializeZones(int numberOfZones, int zoneCapacity, int parkingTime, int timeUnit) { zones = new Zone[numberOfZones]; for(int i = 1; i <= numberOfZones; i++) { zones[i-1] = new Zone(i, zoneCapacity, parkingTime, timeUnit); } }
public ZoneIterator(Zone[] zones) { this.zones = zones; index = 0; }
public void Conscificate(Zone zone, Automobile car, int fine) { monitor.Check(); GlobalParameters globalParameters = GlobalParameters.GetInstance(); int currentTime = globalParameters.Timer; ParkingReservation reservation = FindReservation(zone, car); car.Conscificate(fine); zone.Fines = fine; zone.Remove(car); zone.ConscificatedCars++; reservations.Remove(reservation); ViewerCache viewerCache = ViewerCache.GetInstance(); viewerCache.Add(currentTime.ToString() + ": Automobil " + car.ID.ToString() + " u zoni " + zone.ID.ToString() + " je conscificiran a vlasniku je data kazna u vrijednosti od " + fine.ToString() + " HRK"); monitor.Release(); }
private ParkingReservation FindReservation(Zone zone, Automobile car) { foreach(ParkingReservation reservation in reservations) { if (reservation.Zone == zone && reservation.Car == car) return reservation; } return null; }
public bool ReservePlaceInZone(Automobile car, Zone zone) { monitor.Check(); bool returnValue; if (!open) { returnValue = false; } else if (zone.IsFull()) { GlobalParameters globalParameters = GlobalParameters.GetInstance(); ViewerCache viewerCache = ViewerCache.GetInstance(); zone.LostClients++; viewerCache.Add(globalParameters.Timer.ToString() + ": Automobilu " + car.ID + " odbijeno parkiranje u zoni " + zone.ID.ToString() + " jer nije bilo prostora"); returnValue = false; } else { GlobalParameters globalParameters = GlobalParameters.GetInstance(); int currentTime = globalParameters.Timer; ParkingReservation newReservation = new ParkingReservation(car, zone, currentTime); reservations.Add(newReservation); zone.Add(car); int parkingBill = (zones.Length + 1 - zone.ID) * globalParameters.ArgumentHolder.UnitPrice; car.AddParkingBill(parkingBill); zone.Profit = parkingBill; ViewerCache viewerCache = ViewerCache.GetInstance(); viewerCache.Add(currentTime.ToString() + ": Naplaćeno parkiranje u zoni " + zone.ID.ToString() + " automobilu " + car.ID.ToString() + " u iznosu od " + parkingBill.ToString() + " HRK"); returnValue = true; } monitor.Release(); return returnValue; }