Write a class that implements the following interface.
public interface ICan
{
bool OwnProperty { get; set; }
bool Program();
bool Dance();
}
Can anyone help me please?
C# class
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Feb 14, 2014, 4:01 AM EST
using System;
public interface ICan
{
bool OwnProperty { get; set; }
bool Program();
bool Dance();
}
class Person : ICan
{
string _name;
bool _ownProperty;
bool _canProgram;
bool _canDance;
public string Name
{
get { return _name; }
set { _name = value; }
}
public bool OwnProperty
{
get { return _ownProperty; }
set { _ownProperty = value; }
}
public bool Program()
{
return _canProgram;
}
public bool Dance()
{
return _canDance;
}
public Person(string name, bool ownProperty, bool canProgram, bool canDance)
{
_name = name;
_ownProperty = ownProperty;
_canProgram = canProgram;
_canDance = canDance;
}
}
class Test
{
static void Main()
{
Person v = new Person("Vulpes", true, true, false);
Console.WriteLine("{0} -> \nOwns Property = {1}\nCan Program = {2}\nCan Dance = {3}",
v.Name, v.OwnProperty, v.Program(), v.Dance());
Console.ReadKey();
}
}