Exemple #1
0
        public override string ToString()
        {
            StringBuilder vehicleDetails = new StringBuilder();
            List <Wheel>  wheelsDetails  = VehicleWheels;

            vehicleDetails.Append(string.Format("License Plate: {0}{1}", LicensePlate, Environment.NewLine));
            vehicleDetails.Append(string.Format("Vehicle Model: {0}{1}", Model, Environment.NewLine));
            int wheelNum = 1;

            foreach (Wheel wheel in wheelsDetails)
            {
                vehicleDetails.Append(string.Format("Wheel Number {0}: {1}{2}", wheelNum, wheel.ToString(), Environment.NewLine));
                ++wheelNum;
            }

            if (VehicleEngine is GasEngine)
            {
                vehicleDetails.Append(VehicleEngine.ToString());
                vehicleDetails.Append(Environment.NewLine);
            }

            vehicleDetails.Append(string.Format("Current Energy Percentage: {0}", CurrentEnergyPercentage));
            vehicleDetails.Append(Environment.NewLine);

            return(vehicleDetails.ToString());
        }
Exemple #2
0
 public override string ToString()
 {
     return(string.Format(
                "License number: {1}{0}Model: {2}{0}Status: {3}{0}{4}{0}{5}{0}{6}{0}{7}% of {8} capacity if full.",
                Environment.NewLine,
                r_LicenseNumber,
                r_Model,
                m_Status,
                m_Owner.ToString(),
                m_WheelsList[0].ToString(),
                m_Engine.ToString(),
                m_PercentageOfEnergy,
                m_Engine.Type.ToString()));
 }