Using Visual Studio, create a Console App that:
a. Has a class to encapsulate the following data about a bird:
1.
. English name
i. Latin name
ii. Date last sighted
a. Allows the user to enter the information for a bird;
b. Stores the information in a Bird object; and
c. Displays the information to the user.
internal class Program
{
class Bird
{
public string EnglishName { get; set; }
public string LatinName { get; set; }
public DateTime DateLastSighted { get; set; }
public override string ToString()
{
return $"English name {EnglishName}, Latin name {LatinName}, Date last sighted {DateLastSighted.ToShortDateString()}";
}
}
static void Main(string[] args)
{
Bird bird = new Bird();
Console.Write("Enter the English name of the bird: ");
bird.EnglishName = Console.ReadLine();
Console.Write("Enter the Latin name of the bird: ");
bird.LatinName = Console.ReadLine();
Console.Write("Enter the Date last sighted name of the bird: ");
bird.DateLastSighted = DateTime.Parse(Console.ReadLine());
Console.WriteLine(bird);
Console.ReadKey();
}
}
Comments
Leave a comment