本文整理汇总了C#中IVehicle类的典型用法代码示例。如果您正苦于以下问题:C# IVehicle类的具体用法?C# IVehicle怎么用?C# IVehicle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IVehicle类属于命名空间,在下文中一共展示了IVehicle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VehicleTireReading
public VehicleTireReading(IVehicle CurrentVehicle)
{
Id = Guid.NewGuid();
CurrentTires = CurrentVehicle.Tires;
ReadingTimeStamp = DateTime.UtcNow;
CurrrentDistanceTraveled = CurrentVehicle.OdometerInMiles;
ReadingId = createReadingHashKey(ReadingTimeStamp, CurrentVehicle.Id);
VehicleId = CurrentVehicle.Id;
TypeOfCar = CurrentVehicle.VehicleType;
Readings = new List<TireReading>();
int maxSpeed = 0;
int lastSpeed = 0;
foreach (CarTire ct in CurrentTires)
{
TireReading currentReading = new TireReading(this, ct);
lastSpeed = ct.GetCurrentSpeed();
//Capture the last speed
if (lastSpeed > CurrentSpeed)
{
CurrentSpeed = lastSpeed;
}
maxSpeed = ct.MaxSpeedRating;
Readings.Add(currentReading);
}
}
示例2: StopVehicle
public override void StopVehicle(IVehicle car)
{
switch (car.RadioState)
{
case RadioState.AM:
case RadioState.FM:
case RadioState.XM:
case RadioState.CD:
case RadioState.Off:
{
car.RadioState = RadioState.Off;
break;
}
default:
{
car.RadioState = RadioState.Auxilary;
break;
}
}
car.MessageLog.Add("The car radio state was set.");
if (car.FuelType == FuelType.JetFuel)
{
this.RunEngineCoolingProcess(car);
}
base.StopVehicle(car);
}
示例3: Ticket
public Ticket(IVehicle vehicle, decimal payedMoney, string parkedPlace, int endTime)
{
this.Vehicle = vehicle;
this.PayedMoney = payedMoney;
this.ParkedPlace = parkedPlace;
this.EndTime = endTime;
}
示例4: SteerToAvoid
// XXX 4-23-03: Temporary work around (see comment above)
//
// Checks for intersection of the given spherical obstacle with a
// volume of "likely future vehicle positions": a cylinder along the
// current path, extending minTimeToCollision seconds along the
// forward axis from current position.
//
// If they intersect, a collision is imminent and this function returns
// a steering force pointing laterally away from the obstacle's center.
//
// Returns a zero vector if the obstacle is outside the cylinder
//
// xxx couldn't this be made more compact using localizePosition?
public Vector3 SteerToAvoid(IVehicle v, float minTimeToCollision)
{
// minimum distance to obstacle before avoidance is required
float minDistanceToCollision = minTimeToCollision * v.Speed;
float minDistanceToCenter = minDistanceToCollision + Radius;
// contact distance: sum of radii of obstacle and vehicle
float totalRadius = Radius + v.Radius;
// obstacle center relative to vehicle position
Vector3 localOffset = Center - v.Position;
// distance along vehicle's forward axis to obstacle's center
float forwardComponent = Vector3.Dot(localOffset, v.Forward);
Vector3 forwardOffset = v.Forward * forwardComponent;
// offset from forward axis to obstacle's center
Vector3 offForwardOffset = localOffset - forwardOffset;
// test to see if sphere overlaps with obstacle-free corridor
bool inCylinder = offForwardOffset.Length() < totalRadius;
bool nearby = forwardComponent < minDistanceToCenter;
bool inFront = forwardComponent > 0;
// if all three conditions are met, steer away from sphere center
if (inCylinder && nearby && inFront)
{
return offForwardOffset * -1;
}
else
{
return Vector3.Zero;
}
}
示例5: StartParking
public void StartParking(IVehicle vehicle)
{
Parking parking;
if (_startTimes == null) //normal operation
{
parking = new Parking
{
Vehicle = vehicle,
StartTime = DateTime.Now,
EndTime = default(DateTime)
};
}
else //set startTime manually for testing
{
parking = new Parking
{
Vehicle = vehicle,
StartTime = _startTimes[0],
EndTime = default(DateTime)
};
_startTimes.RemoveAt(0);
}
_currentParkings.Add(parking);
}
示例6: StartParking
public void StartParking(IVehicle vehicle)
{
int numberOfOccupiedParkingSpots = _parkingService.GetNumberOfCurrentParkings();
//check vehicle measurements
if (vehicle.LengthInMeters > ParkingSpotLengthInMeters || vehicle.WidthInMeters > ParkingSpotWidthInMeters)
{
throw new VehicleSizeException("This vehicle is too large to fit in a parking spot");
}
if (numberOfOccupiedParkingSpots == NumberOfParkingSpots)
{
//this could happen if the last empty 10% of parking spots are taken by customers with contracts and noone stops parking at that time
throw new ParkingException("Parking garage is full");
}
//check contract
if (_parkingService.HasParkingContract(vehicle))
{
_parkingService.StartParking(vehicle);
}
else // no contract
{
//check that at least 10% of parking spots are reserved for customers with contracts before allowing to park
if (numberOfOccupiedParkingSpots < NumberOfParkingSpots - RequiredFreeParkingSpots)
{
_parkingService.StartParking(vehicle);
}
else
{
throw new ParkingException("Remaining free parking spots reserved for customers with contracts");
}
}
}
示例7: PrintTicket
private StringBuilder PrintTicket(decimal paidMoney, IVehicle vehicle, int parkingHours, int sector, int place)
{
var totalDueSum = (vehicle.ReservedHours * vehicle.RegularRate) +
(parkingHours > vehicle.ReservedHours ?
(parkingHours - vehicle.ReservedHours) *
vehicle.OvertimeRate : 0);
var change = paidMoney -
((vehicle.ReservedHours * vehicle.RegularRate) +
(parkingHours > vehicle.ReservedHours
? (parkingHours - vehicle.ReservedHours) * vehicle.OvertimeRate
: 0));
var overtimeRtae = parkingHours > vehicle.ReservedHours
? (parkingHours - vehicle.ReservedHours) * vehicle.OvertimeRate
: 0;
var ticket = new StringBuilder();
ticket.AppendLine(new string('*', 20))
.AppendFormat("{0}", vehicle.ToString()).AppendLine()
.AppendFormat("at place ({0},{1})", sector, place).AppendLine()
.AppendFormat("Rate: ${0:F2}", vehicle.ReservedHours * vehicle.RegularRate).AppendLine()
.AppendFormat("Overtime rate: ${0:F2}", overtimeRtae).AppendLine()
.AppendLine(
new string('-', 20))
.AppendFormat("Total: ${0:F2}", totalDueSum).AppendLine()
.AppendFormat("Paid: ${0:F2}", paidMoney).AppendLine().AppendFormat(
"Change: ${0:F2}", change).AppendLine().Append(new string('*', 20));
return ticket;
}
示例8: SimpleTrainMovingStrategy
public SimpleTrainMovingStrategy(IVehicle vehicle)
{
_time = 0;
_vehicle = vehicle;
_timer = new Timer { Interval = _interval };
_timer.Elapsed += (sender, args) => { _time++; };
}
示例9: Park
protected string Park(IVehicle car)
{
if (this.Occupied) {
throw new ApplicationException("Can't park a car in a full space");
}
this.ParkedCar = car;
return this.Id;
}
示例10: LuxuryCar
public LuxuryCar(IVehicle vehicleControls,
IAudioControl audioControls,
IOperateSunRoof sunRoofControls)
{
_vehicleControls = vehicleControls;
_audioControls = audioControls;
_sunRoofControls = sunRoofControls;
}
示例11: CreateSaloon
public virtual IVehicle CreateSaloon()
{
if (saloon == null)
{
saloon = new Saloon(new StandardEngine(1300));
}
return (IVehicle)saloon.Clone();
}
示例12: StopVehicle
public virtual void StopVehicle(IVehicle vehicle)
{
if (vehicle.EngineState == EngineState.Started)
{
vehicle.EngineState = EngineState.Stopped;
vehicle.MessageLog.Add("Stopped the vehicle.");
}
}
示例13: StartVehicle
public override void StartVehicle(IVehicle car)
{
if (car.FuelType == FuelType.Diesel)
{
base.WarmGlowplugs(car);
}
base.StartVehicle(car);
}
示例14: Household
public Household(int id, ITashaPerson[] persons, IVehicle[] vehicles, float expansion, IZone zone)
{
//this.auxiliaryTripChains = new List<ITripChain>(7);
HouseholdId = id;
Persons = persons;
Vehicles = vehicles;
ExpansionFactor = expansion;
HomeZone = zone;
}
示例15: InsertVehicleInDatabase
public void InsertVehicleInDatabase(IVehicle vehicle, int sector, DateTime startTime, string place)
{
this.VehiclesInParkPlaces[vehicle] = place;
this.ParkPlaces[place] = vehicle;
this.VehiclesByLicensePlate[vehicle.LicensePlate] = vehicle;
this.VehiclesByStartTime[vehicle] = startTime;
this.VehiclesByOwner[vehicle.Owner].Add(vehicle);
this.SpacesCount[sector - 1]++;
}