Question

Using C# Create an application class named LetterDemo that instantiates objects of two classes named Letter...

Using C#

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).

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.

This is the code I'm attempting to run is here:

using System;

class Letter

{
public string Recipin_Name { get; set; }
public string Date { get; set; }
public Letter(string Name, string Mailed)

{

Recipin_Name = Name;

Date = Mailed;

}
public override string ToString()

{

return GetType().ToString() + " " + " Recipient Name : " + Recipin_Name + " Date of Mailing : " + Date;

}
}
class CertifiedLetter : Letter

{
public int TrackingNos { get; set; }
public CertifiedLetter(string Name, string date, int track) : base(Name, date)

{

TrackingNos = track;

}

public override string ToString()

{

return GetType().ToString() + " Recipient Name : " + Recipin_Name + " Date Mailed : " + Date + " " + " Tracking of the Number : " + TrackingNos;

}

}
public class Letterdemo

{
public static void Main()

{

CertifiedLetter Certi = new CertifiedLetter("Electric Company", "02/14/18", 08008);

Console.WriteLine(Certi);

Letter letter = new Letter("Electric Company", "02/14/18");

Console.WriteLine(letter);

}

}

But I get these errors:

Build Failed
Compilation failed: 2 error(s), 0 warnings

NtTestc573ab58.cs(10,24): error CS1729: The type `Letter' does not contain a constructor that takes `0' arguments
LetterDemo.cs(8,12): (Location of the symbol related to previous error)
NtTestc573ab58.cs(11,15): error CS1061: Type `Letter' does not contain a definition for `Name' and no extension method `Name' of type `Letter' could be found. Are you missing an assembly reference?
LetterDemo.cs(3,7): (Location of the symbol related to previous error)

And :

Build Failed
Compilation failed: 2 error(s), 0 warnings

NtTestc9948421.cs(10,24): error CS1729: The type `Letter' does not contain a constructor that takes `0' arguments
LetterDemo.cs(8,12): (Location of the symbol related to previous error)
NtTestc9948421.cs(11,15): error CS1061: Type `Letter' does not contain a definition for `Name' and no extension method `Name' of type `Letter' could be found. Are you missing an assembly reference?
LetterDemo.cs(3,7): (Location of the symbol related to previous error)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new Console Application in C# is created using Visual Studio 2017 with name "LetterdemoApp".This application contains a class with name "LetterDemo.cs".Below are the details of this class.

LetterDemo.cs :

//namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//application namespace
namespace LetterdemoApp
{
class Letter //Class Letter
{
//auto-implemented property Name
public string Recipin_Name { get; set; }
//auto-implemented property Date
public string Date { get; set; }
//Constructor
public Letter(string Name, string Mailed)
{
this.Recipin_Name = Name;
this.Date = Mailed;
}
//method ToString()
public override string ToString()
{
return "Type : "+GetType().ToString() + ", " + " Recipient Name : " + Recipin_Name + ", Date of Mailing : " + Date;
}
}
//Class CertifiedLetter
class CertifiedLetter : Letter
{
//auto-implemented property TrackingNos
public int TrackingNos { get; set; }
//Constructor
public CertifiedLetter(string Name, string date, int track) : base(Name, date)
{
this.TrackingNos = track;
}
public override string ToString()
{
return "Type : "+GetType().ToString() + ", Recipient Name : " + Recipin_Name + ", Date Mailed : " + Date + " " + ", Tracking of the Number : " + TrackingNos;
}
}
class LetterDemo //Test class
{
//entry point of application , main method
static void Main(string[] args)
{
//creating object of CertifiedLetter class
CertifiedLetter Certi = new CertifiedLetter("Electric Company", "02/14/18", 08008);
//print details
Console.WriteLine(Certi.ToString());
//creating object of Letter class
Letter letter = new Letter("Electric Company", "02/14/18");
//print details
Console.WriteLine(letter.ToString());
}
}
}

======================================================

Output : Run application using F5 and will get the screen as shown below

Screen 1 :

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
Using C# Create an application class named LetterDemo that instantiates objects of two classes named Letter...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using C#: Create an application class named BillDemo that instantiates objects of two classes named Bill...

    Using C#: Create an application class named BillDemo that instantiates objects of two classes named Bill and OverdueBill, and that demonstrates all their methods. The Bill class includes auto-implemented properties for the name of the company or person to whom the bill is owed and for the amount due. Also, include a ToString() method and returns a string that contains the name of the class (using GetType()) and the Bill’s data fields values. Create a child class named OverdueBill that...

  • Inheritance and Polymorphism (use Pet.java) You are given a class named Pet.java.   Create two child classes...

    Inheritance and Polymorphism (use Pet.java) You are given a class named Pet.java.   Create two child classes named Cat.java and Dog.java. Cat.java should add attributes for color and breed. Dog.java should add attributes for breed and size (use String for small, medium, large). Add appropriate constructors, getter/setter methods and toString() methods.   In a separate file named PetDriver.java, create a main. In the main, create an ArrayList of Pet. Add an instance of Cat and an instance of Dog to the ArrayList....

  • What I need: Create a new program named Reverse4 and declare four integer variables with the...

    What I need: Create a new program named Reverse4 and declare four integer variables with the values 23, 45, 55, and 67. Add a method named Reverse that reverses the positions of four integer variables. The Reverse method should accept the variables as references. Write a Main() method that displays the four variables both before and after reversing them to ensure the method works correctly. What I have: using System; class Reverse4 { public static void reverse(ref int num1, ref...

  • // Client application class and service class Create a NetBeans project named StudentClient following the instructions...

    // Client application class and service class Create a NetBeans project named StudentClient following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. Add a class named Student to the StudentClient project following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. After you have created your NetBeans Project your application class StudentC lient should contain the following executable code: package studentclient; public class...

  • Please Write the following program in c# You are to write an application which will create...

    Please Write the following program in c# You are to write an application which will create a company, add agents (their name, ID, and weekly sales) to that company, and printout the details of all agents in the company. The application will contain three classes: Agent.cs, Company.cs, and CompanyTest.cs (this class is already provided). Flow of the application: The CompanyTest class creates an object of the Company class and reserves space for five agents. At this point if you call...

  • Concepts Tested in this Program: Class Design Constructors Objects Inheritance Program:   Design a class named Person...

    Concepts Tested in this Program: Class Design Constructors Objects Inheritance Program:   Design a class named Person and its two subclasses, Student and Employee. Make Faculty and Staff subclasses of Employee. A Person object has a name, address, phone number, and email address (all Strings). A Student Object has a class status (freshman, sophomore, junior, or senior). Define the status as a final String variable. An Employee Object has an office number, salary (both ints ), and a date hired. Use...

  • In a project named 'DogApplication', create a class called 'Dog' 1. declare two instance variables in...

    In a project named 'DogApplication', create a class called 'Dog' 1. declare two instance variables in 'Dog' : name (String type) age (int type) 2. declare the constructor for the 'Dog' class that takes two input parameters and uses these input parameters to initialize the instance variables 3. create another class called 'Driver' and inside the main method, declare two variables of type 'Dog' and call them 'myDog' and 'yourDog', then assign two variables to two instance of 'Dog' with...

  • C# Hey I am having trouble implementing additonal function to this assignment: Problem: Implement three IComparer classes on Employee - NameComparer, AgeComparer, and PayComparer - that allow Employee...

    C# Hey I am having trouble implementing additonal function to this assignment: Problem: Implement three IComparer classes on Employee - NameComparer, AgeComparer, and PayComparer - that allow Employees to be compared by the Name, Age, and Pay, respectively. Code: Employee.Core.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Employees { partial class Employee { // Field data. private string empName; private int empID; private float currPay; private int empAge; private string empSSN = ""; private string empBene...

  • I need help with my code. It keeps getting this error: The assignment is: Create a...

    I need help with my code. It keeps getting this error: The assignment is: Create a class to represent a Food object. Use the description provided below in UML. Food name : String calories : int Food(String, int) // The only constructor. Food name and calories must be // specified setName(String) : void // Sets the name of the Food getName() : String // Returns the name of the Food setCalories(int) : void // Sets the calories of the Food...

  • Create a Java application named Problem14 using the two files Dr. Hanna provided to you—Date.java andProblem14.java—then change his code to add two non-trivial public, non-static methods to the Date class.

    Create a Java application named Problem14 using the two files Dr. Hanna provided to you—Date.java andProblem14.java—then change his code to add two non-trivial public, non-static methods to the Date class.1. Increment a Date to the next day (for example, 1-31-2011 increments to 2-1-2011; 12-31-2010 increments to 1-1-2011).2. Decrement a Date to the previous day (for example, 2-1-1953 decrements to 1-31-1953; 1-1-1954 decrements to 12-31-1953).. Extra Credit (up to 5 points) Re-write the Date member functions Input() and Output() to usedialog boxes to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT