本文整理汇总了C#中IVehicle.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IVehicle.GetType方法的具体用法?C# IVehicle.GetType怎么用?C# IVehicle.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVehicle
的用法示例。
在下文中一共展示了IVehicle.GetType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Move
public static void Move(IVehicle v)
{
Console.WriteLine("Moving a " + v.GetType().Name + " running on " + v.Fuel.fuel_amount + " liters of " + v.Fuel.GetType().Name + ".");
while (v.Move())
{
//System.Threading.Thread.Sleep(300);
v.Kilometers_Moved += 1;
v.Fuel.fuel_amount -= 5;
//Console.WriteLine(v.GetType().Name + " moved " + v.Kilometers_Moved + " km.");
//if (v.Fuel.fuel_amount > 0)
//{
// Console.WriteLine("Gas now at " + v.Fuel.fuel_amount + " liters.");
//}
}
Console.WriteLine("Finished moving " + v.GetType().Name + " " + v.Kilometers_Moved + " km.");
Console.WriteLine("Gas now at " + v.Fuel.fuel_amount + " liters.\n");
}
示例2: InsertVehicle
private string InsertVehicle(IVehicle vehicle, int sector, int place, DateTime parkedTime)
{
if (sector > this.layout.Sectors || sector <= 0)
{
return string.Format("There is no sector {0} in the park", sector);
}
if (place > this.layout.PlacesPerSector || place <= 0)
{
return string.Format("There is no place {0} in sector {1}", place, sector);
}
if (this.data.LicensePlates_Vehicles.ContainsKey(vehicle.LicensePlate))
{
var errorMessage = string.Format(
"There is already a vehicle with license plate {0} in the park",
vehicle.LicensePlate);
return errorMessage;
}
var vehiclePlace = string.Format("({0},{1})", sector, place);
if (this.data.Parking.ContainsKey(vehiclePlace))
{
var errorMessage = string.Format("The place {0} is occupied", vehiclePlace);
return (errorMessage);
}
this.data.CarPosisitionInPark[vehicle] = vehiclePlace;
this.data.Parking[vehiclePlace] = vehicle;
this.data.LicensePlates_Vehicles[vehicle.LicensePlate] = vehicle;
this.data.VehicleEnterDate[vehicle] = parkedTime;
this.data.OwnerVecihles[vehicle.Owner].Add(vehicle);
this.data.OccupiedParkPlacesCountPerSector[sector - 1]++;
return string.Format("{0} parked successfully at place {1}", vehicle.GetType().Name, vehiclePlace);
}
示例3: InsertVehicle
public string InsertVehicle(IVehicle vehicle, int sector, int placeInSector, DateTime timeOfEntry)
{
if (this.database.VehiclesByLicensePlate.ContainsKey(vehicle.LicensePlate))
{
throw new ArgumentException(string.Format(GlobalMessages.VehicleAlreadyParked, vehicle.LicensePlate));
}
if (sector > this.Sectors || sector < 1)
{
throw new ArgumentException(string.Format(GlobalMessages.NoSuchSector, sector));
}
if (placeInSector > this.PlacesPerSector || placeInSector < 0)
{
throw new ArgumentException(string.Format(GlobalMessages.NoSuchPlaceInSector, placeInSector, sector));
}
string parkingSpace = "(" + sector + "," + placeInSector + ")";
if (this.database.VehiclesByParkingSpace.ContainsKey(parkingSpace))
{
throw new ArgumentException(string.Format(GlobalMessages.PlaceIsOccupied, parkingSpace));
}
vehicle.TimeOfEntry = timeOfEntry;
this.database.VehicleEntryTimes.Add(vehicle, timeOfEntry);
this.database.VehiclesByLicensePlate.Add(vehicle.LicensePlate, vehicle);
this.database.VehiclesByOwner.Add(vehicle.Owner, vehicle);
this.database.VehiclesByParkingSpace.Add(parkingSpace, vehicle);
this.database.VehicleParkingSpace.Add(vehicle, parkingSpace);
this.database.SectorSpacesTaken[sector - 1]++;
return string.Format(GlobalMessages.VehicleParked, vehicle.GetType().Name, parkingSpace);
}
示例4: InsertVehicle
private string InsertVehicle(IVehicle vehicle, int sector, int place, DateTime entrytime)
{
if (sector > this.layout.Sectors)
{
return string.Format("There is no sector {0} in the park", sector);
}
if (place > this.layout.Places)
{
return string.Format("There is no place {0} in sector {1}", place, sector);
}
if (this.database.VehicleByPosition.ContainsKey(string.Format("({0},{1})", sector, place)))
{
return string.Format("The place ({0},{1}) is occupied", sector, place);
}
if (this.database.VehiclesByLicensePlate.ContainsKey(vehicle.LicensePlate))
{
return string.Format(
"There is already a vehicle with license plate {0} in the park",
vehicle.LicensePlate);
}
this.database.AddVehicle(vehicle, sector, place, entrytime);
return string.Format("{0} parked successfully at place ({1},{2})", vehicle.GetType().Name, sector, place);
}
示例5: InsertVehicle
private string InsertVehicle(IVehicle vehicle, int sector, int place, DateTime time)
{
if (sector > this.layout.NumberOfSectors)
{
return string.Format(Message.NoSector, sector);
}
if (place > this.layout.PlacesPerSector)
{
return string.Format(Message.NoPlace, place, sector);
}
if (!this.vehicleParkData.IsEmptyPlace(sector, place))
{
return string.Format(Message.PlaceOccupied, sector, place);
}
if (this.vehicleParkData.HasParkedWithLicense(vehicle.LicensePlate))
{
return string.Format(Message.DuplicateLicense, vehicle.LicensePlate);
}
this.vehicleParkData.InsertVehicle(vehicle, sector, place, time);
return string.Format(Message.ParkedSucessfully, vehicle.GetType().Name, sector, place);
}
示例6: InsertVehicle
private string InsertVehicle(IVehicle vehicle, int sector, int placeNumber, DateTime startTime)
{
string commandResult = null;
if (sector > this.layout.Sectors)
{
commandResult = string.Format("There is no sector {0} in the park", sector);
return commandResult;
}
if (placeNumber > this.layout.PlacesPerSector)
{
commandResult = string.Format("There is no place {0} in sector {1}", placeNumber, sector);
return commandResult;
}
string place = this.GenerateParkPlaceKey(sector, placeNumber);
if (this.data.ParkPlaces.ContainsKey(place))
{
commandResult = string.Format("The place ({0},{1}) is occupied", sector, placeNumber);
return commandResult;
}
if (this.data.VehiclesByLicensePlate.ContainsKey(vehicle.LicensePlate))
{
commandResult = string.Format(
"There is already a vehicle with license plate {0} in the park",
vehicle.LicensePlate);
return commandResult;
}
this.data.InsertVehicleInDatabase(vehicle, sector, startTime, place);
commandResult = string.Format(
"{0} parked successfully at place ({1},{2})",
vehicle.GetType().Name,
sector,
placeNumber);
return commandResult;
}
示例7: InsertVehicle
private string InsertVehicle(IVehicle vehicle, int numberOfSector, int placesInSector, DateTime startTime)
{
if (numberOfSector > this.layout.Sectors)
{
return string.Format("There is no sector {0} in the park", numberOfSector);
}
if (placesInSector > this.layout.PlacesPerSector)
{
return string.Format("There is no place {0} in sector {1}", placesInSector, numberOfSector);
}
if (this.data.Park.ContainsKey(string.Format("({0},{1})", numberOfSector, placesInSector)))
{
// The place (1,5) is occupied
return string.Format("The place ({0},{1}) is occupied", numberOfSector, placesInSector);
}
if (this.data.NumberVehicle.ContainsKey(vehicle.LicensePlate))
{
// There is already a vehicle with license plate CA1001HH in the park
return string.Format(
"There is already a vehicle with license plate {0} in the park",
vehicle.LicensePlate);
}
this.AddVehicleToPark(vehicle, numberOfSector, placesInSector, startTime);
return string.Format(
"{0} parked successfully at place ({1},{2})",
vehicle.GetType().Name,
numberOfSector,
placesInSector);
}
示例8: InsertVehicle
private string InsertVehicle(IVehicle vehicle, int sector, int placeNumber, DateTime startTime)
{
if (sector > this.parkLayout.NumberOfSectors)
{
return string.Format("There is no sector {0} in the park", sector);
}
if (placeNumber > this.parkLayout.PlacesPerSector)
{
return string.Format("There is no place {0} in sector {1}", placeNumber, sector);
}
if (this.parkData.VehiclesBySectorAndPlace.ContainsKey(string.Format("({0},{1})", sector, placeNumber)))
{
return string.Format("The place ({0},{1}) is occupied", sector, placeNumber);
}
if (this.parkData.VehiclesByLicensePLate.ContainsKey(vehicle.LicensePlate))
{
return string.Format("There is already a vehicle with license plate {0} in the park", vehicle.LicensePlate);
}
this.parkData.VehiclesInPark[vehicle] = string.Format("({0},{1})", sector, placeNumber);
this.parkData.VehiclesBySectorAndPlace[string.Format("({0},{1})", sector, placeNumber)] = vehicle;
this.parkData.VehiclesByLicensePLate[vehicle.LicensePlate] = vehicle;
this.parkData.VehiclesByStartDate[vehicle] = startTime;
this.parkData.VehiclesByOwner[vehicle.Owner].Add(vehicle);
this.parkData.NumberOfSectors[sector - 1]--;
return string.Format("{0} parked successfully at place ({1},{2})", vehicle.GetType().Name, sector, placeNumber);
}
示例9: InsertVehicle
public string InsertVehicle(IVehicle vehicle, int sector, int place, DateTime startTime)
{
if (sector > this.layout.SectorsCount)
{
return string.Format("There is no sector {0} in the park", sector);
}
if (place > this.layout.SectorPlacesNumber)
{
return string.Format("There is no place {0} in sector {1}", place, sector);
}
if (this.data.OccupiedParkingPlaces.ContainsKey(string.Format("({0},{1})", sector, place)))
{
return string.Format("The place ({0},{1}) is occupied", sector, place);
}
if (this.data.VehiclesByPlate.ContainsKey(vehicle.LicensePlate))
{
return string.Format("There is already a vehicle with license plate {0} in the park", vehicle.LicensePlate);
}
this.data.CarsInPark[vehicle] = string.Format("({0},{1})", sector, place);
this.data.OccupiedParkingPlaces[string.Format("({0},{1})", sector, place)] = vehicle;
this.data.VehiclesByPlate[vehicle.LicensePlate] = vehicle;
this.data.VehiclesParkingStartDate[vehicle] = startTime;
this.data.CarsByOwner[vehicle.Owner].Add(vehicle);
this.data.OccupiedPlacesBySector[sector - 1]++;
return string.Format("{0} parked successfully at place ({1},{2})", vehicle.GetType().Name, sector, place);
}
示例10: InsertVehicle
private string InsertVehicle(IVehicle vehicle, int sector, int place, DateTime startTime)
{
if (sector > this.VehicleParkLayout.NumberOfSectors)
{
return string.Format(Messages.InvalidSector, sector);
}
if (place > this.VehicleParkLayout.SectorPlacesPerSector)
{
return string.Format(Messages.InvalidPlace, place, sector);
}
if (this.VehicleParkData.ParkPlaces.ContainsKey(string.Format("({0},{1})", sector, place)))
{
return string.Format(Messages.PlaceAlreadyOccupied, sector, place);
}
if (this.VehicleParkData.VehiclesByLicensePlate.ContainsKey(vehicle.LicensePlate))
{
return string.Format(Messages.DuplicateLicensePlate, vehicle.LicensePlate);
}
this.AddVehicleToParkData(vehicle, sector, place, startTime);
return string.Format(Messages.ParkedVehicle, vehicle.GetType().Name, sector, place);
}
示例11: InsertVehicle
public string InsertVehicle(IVehicle vehicle, int sector, int placeNumber, DateTime startTime)
{
if (sector > layout.NumberOfSectors)
{
return string.Format("There is no sector {0} in the park", sector);
}
if (placeNumber > layout.PlacesPerSector)
{
return string.Format("There is no place {0} in sector {1}", placeNumber, sector);
}
if (data.VehicleByLocation.ContainsKey(string.Format("({0},{1})", sector, placeNumber)))
{
return string.Format("The place ({0},{1}) is occupied", sector, placeNumber);
}
if (data.VehicleByLicensePlate.ContainsKey(vehicle.LicensePlate))
{
return string.Format("There is already a vehicle with license plate {0} in the park",
vehicle.LicensePlate);
}
data.AddVehicle(vehicle, sector, placeNumber, startTime);
return string.Format("{0} parked successfully at place ({1},{2})", vehicle.GetType().Name, sector, placeNumber);
}