Can someone tell me if I am on the right track?

Can someone tell me if I am on the right track with these instructions? Create an application class named 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). Create a child class named CertifiedLetter that includes an auto-implemented property TrackingNumber (of type string) that holds a tracking number for the letter. 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 respective class's data field values. Use default, empty constructor for both classes.
using System;
using static System.Console;
using System.Globalization;
class LetterDemo
{
static void Main()
{
class LetterDemo
{
static void Main(string[] args)
{
LetterObject = new Letter();
CertifiedLetter = new CertifiedLetter()
}
}


public class Letter()
{

// Set the class properties
private string name;
private string dateMailed;

// Get set methods
public string Name
{
get {return name; }
set { name = value; }
}

// Property for DateMailed
public string DateMailed
{
get {return dateMailed; }
set {dateMailed = value; }
}

// Override the ToString() method
public ovveride string ToString()
{
return $"Name {Name},
}
}

public class CertifieddLetter : Letter
{

public string TrackingNumber {get; set};


}
}
}
using System;
using static System.Console;
using System.Globalization;
class LetterDemo
{
static void Main()
{
class LetterDemo
{
static void Main(string[] args)
{
LetterObject = new Letter();
CertifiedLetter = new CertifiedLetter()
}
}


public class Letter()
{

// Set the class properties
private string name;
private string dateMailed;

// Get set methods
public string Name
{
get {return name; }
set { name = value; }
}

// Property for DateMailed
public string DateMailed
{
get {return dateMailed; }
set {dateMailed = value; }
}

// Override the ToString() method
public ovveride string ToString()
{
return $"Name {Name},
}
}

public class CertifieddLetter : Letter
{

public string TrackingNumber {get; set};


}
}
}
1 Reply
canton7
canton77d ago
You're starting to get there. Some things to pay attention to: * Classes should be declared directly in a namespace: you can't declare a class inside a method * Classes are delcared with class Letter, not class Letter() * The instructions say to use auto-implemented properties * The instructions say what ToString should do, specifically * The instructions say that you should test all of the methods of your classes * The C# syntax for declaring a variable is e.g. Letter letter. To assign a new instance of Letter to that variable, you do e.g letter = new Letter(). To do the two together, you do e.g. Letter letter = new Letter() There are lots of typos in your code. If you try to compile your code, the compiler will tell you what the mistakes are Talking about non-empty ctors, static create methods, required/init properties, etc, is not relevant or helpful. OP is obviously just starting out Same!

Did you find this page helpful?