Create an ct application class named MailDemo that instantiates objects of two c
ID: 3709827 • Letter: C
Question
Create an ct application class named MailDemo that instantiates objects of two classes named Letter and CertifiedMai and that demonstrates all their methods. The classes are used by a company to keep track of letters they ma ?? to cïients. The Letter class includes auto-impÏemented properties for the name of the recipient and the date mailed. Also, include a ToString ) method that overrides the Object class' ToString) method and returns a string that contains the name of the class (using GetType ()) and the Letter's data field values. Create a child class named CertifiedMail that includes an auto-implemented property that holds a tracking number for the letter *Please include scree nshot of code and output.Explanation / Answer
using System;
class Letter // base class
{
// Auto-Implemented Properties for recipient name and date mailed
public string RecipientName { get; set; }
public string DateMailed { get; set; }
public Letter(string recipientName,string dateMailed)
{
RecipientName = recipientName;
DateMailed = dateMailed;
}
public override string ToString()
{
return GetType().ToString()+" "+" Recipient Name : "+RecipientName+" Date Mailed : "+DateMailed;
}
}
class CertifiedMail : Letter // derived class
{
// Auto-Implemented Property for tracking number
public int TrackingNumber { get; set; }
public CertifiedMail(string recipientName,string dateMailed,int trackingNumber):base(recipientName,dateMailed)
{
TrackingNumber = trackingNumber;
}
public override string ToString()
{
return GetType().ToString()+" Recipient Name : "+RecipientName+" Date Mailed : "+DateMailed +" "+" Tracking Number : "+TrackingNumber;
}
}
public class Maildemo
{
public static void Main()
{
CertifiedMail cm = new CertifiedMail("Mr. Mathew Buckner","March,20,2017",756887);
Console.WriteLine(cm);
Letter l = new Letter("Cathy Williams","Jan 23,2011");
Console.WriteLine(l);
}
}
Output:
CertifiedMail Recipient Name : Mr. Mathew Buckner Date Mailed : March,20,2017 Tracking Number : 756887
Letter Recipient Name : Cathy Williams Date Mailed : Jan 23,2011
?Do ask if any doubt. Please upvote.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.