Using Visual Studios C Make Sure Make Two Instances Pet Class Pet Able Walk Talk Also Able Q37133184

Using Visual Studios C#

Make sure to make two instances of a pet class. The pet shouldbe able to walk and talk. You should also be able to set it’s AgeName, and Type (cat, dog). Make sure to set and show values foreach of the three properties (variables): Name, Type, Age. Makesure to execute the walk and talk (just display messages “I amwalking”, “I am talking.”)


Solution


using System;

class Pet

{

private string name,type;

private int age;

//properties

public string Name

{

get

{

return name;

}

set

{

name = value;

}

}

public string Type

{

get

{

return type;

}

set

{

type = value;

}

}

public int Age

{

get

{

return age;

}

set

{

age = value;

}

}

public void walk()

{

Console.WriteLine(“I am walking”);

}

public void talk()

{

Console.WriteLine(“I am talking”);

}

}

class MainClass

{

public static void Main()

{

Pet

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.