At the time of developing the code in c# winforms, i have a problem..
In composite pattern, code is like
//Interface
interface Usage
{
public abstract void getinfo();
public abstract void add(Usage u);
}
//Leaf
class status : Usage
{
public string strng;
public status()
{
this.strng = "Hello";
}
public override void getinfo()
{
}
public override void add(Usage u)
{
}
}
//Composite class
class composite : Usage
{
string strng;
ArrayList node=new ArrayList();
public override void add(Usage u)
{
node.Add(u);
}
public override void getinfo()
{
foreach (Usage u in this.node)
{
u.getinfo();
}
}
}
But i was unable to capture the string strng
which is Leaf
(status)class? return type of getinfo() method is VOID
.But because of interface method implementation i cannot make it STRING
return type.
anyone please Resolve my problem.
Thanks in advance.