I have a library and theres one problem with the logic in my program. If you can help me - i will say you : "Thank you" . really big thanks. Code :
public class Report
{
/// <summary>
/// An empty constructor, just instantiates the object.
/// </summary>
public Report()
{
}
/// <summary>
/// A method that receives a message from another object,
/// and prints it out to the Console.
/// </summary>
/// <param name="message">The message to be printed.</param>
public void ReceiveMessage(String message)
{
Console.WriteLine(message);
}
}
private Report reportObject;
public void EnterThinkingState() {
Thread.Sleep(rng.Next(1000) + 1);
Status = "thinking";
reportObject.ReceiveMessage(Name + " is " + Status);
Thread.Sleep(rng.Next(1000) + 1);
}
the Question is : My classes - are a library. How can i create an adaptive method (Receive) that a user could use to output information wherever he wants(logger,console,file e.t.c). should i use virtual methods? Or create an interface? Or how can i bind it with events?I know how to use events if we talk about typical situation. Thank you for the help. And, again, sorry for my bad English.