//tostring override method to return values of data fields as strings //displays costs and fees //preconditions: none //postconditions: a formatted string for the output public override string ToString() { //simplified newline string nl = Environment.NewLine; return("Origin Address:" + nl + OriginAddress.ToString() + nl + nl + "Destination Address:" + nl + DestinationAddress.ToString() + nl + "Cost: " + CalcCost().ToString("C")); }
//Override the to string and print the origin, destionation and cost public override string ToString() { return(string.Format("Origin: " + Environment.NewLine + "{0} \n\nDestintion: " + Environment.NewLine + "{1} " + Environment.NewLine + "Costs: {2}", OriginAddress.ToString(), DestinationAddress.ToString(), CalcCost().ToString("C"))); }
// Preconditions: No specific restrictions // Postconditions: Returns the data about the parcel as a formatted string. public override string ToString() { return(string.Format("Origin Address:" + OriginAddress.ToString() + System.Environment.NewLine + "Destination Address:" + DestinationAddress.ToString() + System.Environment.NewLine + "Cost:" + CalcCost())); }
// Preconditions: No specific restrictions // Postconditions: Returns the data about the letter as a formatted string. public override string ToString() { return(string.Format("Origin Address: " + System.Environment.NewLine + OriginAddress.ToString() + "\n\nDestination Address: " + System.Environment.NewLine + DestinationAddress.ToString() + "\n\nCost: " + CalcCost().ToString("c") + System.Environment.NewLine + "------------------------------------")); }