当前位置: 首页>>代码示例>>C#>>正文


C# IVehicle.ToString方法代码示例

本文整理汇总了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();
        }
开发者ID:exploitx3,项目名称:HighQualityCode,代码行数:20,代码来源:VehiclePark.cs

示例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;
        }
开发者ID:PlamenaMiteva,项目名称:Quality-Programming-Code,代码行数:28,代码来源:ExitvehicleTests.cs

示例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();
        }
开发者ID:nok32,项目名称:SoftUni,代码行数:22,代码来源:VehiclePark.cs


注:本文中的IVehicle.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。