Write a class that implements the following interface.
public interface ICan
{
bool OwnProperty { get; set; }
bool Program();
bool Dance();
}
Can anyone help me please?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Feb 14, 2014, 9:01 AM
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();
}
}