public override string ToString() { StringBuilder sb = new StringBuilder() .AppendLine("Vehicle Details:") .AppendLine("Type: " + Converter.StringFromType(r_VehicleType)) .AppendLine("Model Name: " + r_ModelName) .AppendLine("ID: " + r_ID) .AppendLine("Engine Info:") .AppendLine(r_Engine.ToString()); sb.AppendLine("Wheels Details:"); foreach (Wheel wheel in r_Wheels) { sb.AppendLine(wheel.ToString()); } if (r_Components != null) { sb.AppendLine("Extra Details:"); foreach (Component component in r_Components) { sb.AppendLine(component.ToString()); } } return(sb.ToString()); }
public override string ToString() { const string k_NotSet = "[Not Set]"; StringBuilder sb = new StringBuilder(); sb.AppendLine("Current Vehicle Information:"); sb.Append("Vehicle Type: "); sb.AppendLine(Converter.StringFromType(m_VehicleType)); sb.Append("ID: "); sb.AppendLine(m_VehicleID ?? k_NotSet); sb.Append("Model: "); sb.AppendLine(m_ModelName ?? k_NotSet); sb.Append("Engine: "); sb.AppendLine(m_Engine != null ? m_Engine.ToString() : k_NotSet); int numWheels = m_Wheels != null ? m_Wheels.Count : 0; sb.Append("Wheels [" + numWheels + "]:"); if (m_Wheels != null) { foreach (Wheel wheel in m_Wheels) { sb.AppendLine(); sb.AppendLine(wheel.ToString()); } } else { sb.AppendLine(k_NotSet); } sb.AppendLine("Extra Details:"); if (m_Components != null) { foreach (Component component in m_Components) { sb.AppendLine(); sb.AppendLine(component.ToString()); } } else { sb.AppendLine(k_NotSet); } sb.AppendLine("Vehicle status:"); string readyMessage = isReady() ? "Ready to add vehicle (press 11)" : "Not enough information, provide more details"; sb.AppendLine(readyMessage); return(sb.ToString()); }