Using C#. Create an application classnamed LetterDemo that instantiates objects
ID: 3714529 • Letter: U
Question
Using C#. Create an application classnamed LetterDemo that instantiates objects of two classes named Letter and CertifiedLetter and that demonstrates all their methods.The classes are used by a company to keep track of letters they mail to clients. The Letter class includes auto-implemented properties for the Name of the recipient and the Date mailed (stored as strings).
Next, include a ToString() method that overrides the Object class’s 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 CertifiedLetter that includes an auto-implemented property TrackingNumber (of type string) that holds a tracking number for the letter.
Explanation / Answer
Below is your code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Console;
namespace ConsoleApp16
{
class LetterDemo
{
static void Main(string[] args)
{
Letter letter1 = new Letter();
letter1.name = " Sender: Justin";
letter1.date = (" Date: March 4,2017 ");
CertifiedLetter track = new CertifiedLetter();
Write("Your letter has been recieved!");
Write(" ");
Write(letter1);
Write(" ");
Write("Tracking number:"+ track.GetHashCode());
Write(" ");
}
}
}
class Letter
{
public string name { get; set; }
public string date { get; set; }
public override string ToString()
{
return (GetType() + ":" + this.name + "" + this.date);
}
}
class CertifiedLetter : Letter
{
public string trackingNumber { get; set; }
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.