Ejemplo n.º 1
0
 private static List <Boat> RemoveMotorBoatFromParking(MotorBoat motorBoat, List <Boat> parkedBoats)
 {
     var(parkingPlaceHasValue, parkingPlace) = ParkingPlaceHasFound(motorBoat);
     if (parkingPlaceHasValue)
     {
         harbour[parkingPlace.Key] = null;
         parkedBoats.Remove(motorBoat);
         emptyParking += 1;
     }
     return(parkedBoats);
 }
Ejemplo n.º 2
0
 private static void ParkMotorBoat(MotorBoat boat)
 {
     for (int i = 1; i <= harbour.Count; i++)
     {
         if (harbour[i] == null)
         {
             harbour[i]        = boat.IdentityNumber;
             boat.ParkingPlace = $"{ i }";
             _parkedBoats.Add(boat);
             emptyParking -= boat.RequiredParkingPlace;
             dockedCount  += 1;
             break;
         }
     }
 }
Ejemplo n.º 3
0
        public static List <Boat> ReadBoatInfoFromFile()
        {
            var boats = new List <Boat>();

            const string filePath = @"C:\Visual Stadio\HarbourManagement\DockedBoatsInHarbor.csv";

            foreach (string boat in File.ReadLines(filePath, System.Text.Encoding.UTF7))
            {
                char[]   delimiterChars = { ' ', ',', '(', ')' };
                string[] boatData       = boat.Trim().Split(delimiterChars);
                if (boatData[1] == "RowingBoat")
                {
                    var rowingBoat = new RowingBoat(boatData[1], boatData[3],
                                                    int.Parse(boatData[5]), int.Parse(boatData[7]), int.Parse(boatData[9]), int.Parse(boatData[11]));
                    rowingBoat.ParkingPlace       = boatData[13];
                    BerthManagement.emptyParking -= .5;
                    boats.Add(rowingBoat);
                }
                else if (boatData[1] == "MotorBoat")
                {
                    var motorBoat = new MotorBoat(boatData[1], boatData[3],
                                                  int.Parse(boatData[5]), int.Parse(boatData[7]), int.Parse(boatData[9]), int.Parse(boatData[11]));
                    motorBoat.ParkingPlace        = boatData[13];
                    BerthManagement.emptyParking -= 1;
                    boats.Add(motorBoat);
                }
                else if (boatData[1] == "SailBoat")
                {
                    var sailBoat = new SailBoat(boatData[1], boatData[3],
                                                int.Parse(boatData[5]), int.Parse(boatData[7]), int.Parse(boatData[9]), int.Parse(boatData[11]));
                    sailBoat.ParkingPlace         = boatData[13];
                    BerthManagement.emptyParking -= 2;
                    boats.Add(sailBoat);
                }
                else if (boatData[1] == "CargoShip")
                {
                    var cargoShip = new CargoShip(boatData[1], boatData[3],
                                                  int.Parse(boatData[5]), int.Parse(boatData[7]), int.Parse(boatData[9]), int.Parse(boatData[11]));
                    cargoShip.ParkingPlace        = boatData[13];
                    BerthManagement.emptyParking -= 4;
                    boats.Add(cargoShip);
                }
            }
            return(boats);
        }