Exemple #1
0
        public override string ToString()
        {
            return(string.Format(
                       @"License number is: {0}
Model name is: {1}
Owner name is: {2}
Current state in garage: {3}
{4}
Current energy percentage is: {5}%
{6}",
                       m_LicenseNumber,
                       m_ModelName,
                       m_OwnerName,
                       m_VehicleGarageStatus,
                       m_Wheels[0].ToString(),
                       m_EnergyPercentage,
                       m_EnergySource.ToString()));
        }
        public override string ToString()
        {
            StringBuilder vehicleString = new StringBuilder();

            vehicleString.AppendFormat("Model Name: {0}, ", ModelName);
            vehicleString.AppendFormat("License Number: {0}, ", r_LicenseNumber);
            vehicleString.AppendFormat("Remaining Energy: {0}% ", m_PercentageRemainingEnergy);
            vehicleString.AppendLine();
            vehicleString.AppendFormat("Energy Source: {0} {1}", Environment.NewLine,
                                       m_EnergySource.ToString());
            vehicleString.AppendLine();
            vehicleString.AppendFormat("Wheels: ");
            vehicleString.AppendLine();

            foreach (Wheel wheel in m_Wheels)
            {
                vehicleString.AppendFormat(wheel.ToString());
                vehicleString.AppendLine();
            }

            return(vehicleString.ToString());
        }