本文整理汇总了C#中IVehicle.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IVehicle.ToString方法的具体用法?C# IVehicle.ToString怎么用?C# IVehicle.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVehicle
的用法示例。
在下文中一共展示了IVehicle.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintTicket
private string PrintTicket(IVehicle vehicle, int hours, decimal amountPaid)
{
var ticket = new StringBuilder();
decimal rate = vehicle.ReservedHours * vehicle.RegularRate;
decimal overtimeRate = hours > vehicle.ReservedHours ? (hours - vehicle.ReservedHours) * vehicle.OvertimeRate : 0;
string ticketSeparator = new string('*', 20);
string innerSeparator = new string('-', 20);
ticket.AppendLine(ticketSeparator)
.AppendFormat("{0}", vehicle.ToString()).AppendLine()
.AppendFormat("at place {0}", this.data.VehiclesInParkPlaces[vehicle]).AppendLine()
.AppendFormat("Rate: ${0:F2}", rate).AppendLine()
.AppendFormat("Overtime rate: ${0:F2}", overtimeRate).AppendLine()
.AppendLine(innerSeparator)
.AppendFormat("Total: ${0:F2}", rate + overtimeRate).AppendLine()
.AppendFormat("Paid: ${0:F2}", amountPaid).AppendLine()
.AppendFormat("Change: ${0:F2}", amountPaid - (rate + overtimeRate)).AppendLine()
.Append(ticketSeparator);
return ticket.ToString();
}
示例2: 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;
}
示例3: GetTicket
private string GetTicket(IVehicle vehicle, int endTime, decimal money)
{
var ticket = new StringBuilder();
ticket.AppendLine(new string(DefaultTicketOuterSymbol, DefaultTicketSymbolCount))
.AppendLine(vehicle.ToString())
.AppendLine(string.Format("at place {0}", this.VehicleParkData.VehiclesInParkPlaces[vehicle]))
.AppendLine(string.Format("Rate: ${0:F2}", vehicle.ReservedHours * vehicle.RegularRate))
.AppendLine(string.Format(
"Overtime rate: ${0:F2}",
endTime > vehicle.ReservedHours ? (endTime - vehicle.ReservedHours) * vehicle.OvertimeRate : 0))
.AppendLine(string.Format(new string(DefaultTicketInnerSymbol, DefaultTicketSymbolCount)))
.AppendLine(string.Format(
"Total: ${0:F2}",
(vehicle.ReservedHours * vehicle.RegularRate) + (endTime > vehicle.ReservedHours ? (endTime - vehicle.ReservedHours) * vehicle.OvertimeRate : 0)))
.AppendLine(string.Format("Paid: ${0:F2}", money))
.AppendLine(string.Format(
"Change: ${0:F2}",
money - ((vehicle.ReservedHours * vehicle.RegularRate) + (endTime > vehicle.ReservedHours ? (endTime - vehicle.ReservedHours) * vehicle.OvertimeRate : 0))))
.Append(new string(DefaultTicketOuterSymbol, DefaultTicketSymbolCount));
return ticket.ToString();
}