We have some document-types:
class Document
{
public void virtual Print()
}
class PDF : Document
{
public void override Print()
{
Console.WriteLine("PDF Printed");
}
}
class Excel : Document
{
public void override Print()
{
Console.WriteLine("Excel Printed");
}
}
Suppose we have a list of documents (Document objects) and we call the virtual function Print() on all of them.
foreach(Document doc in DocumentsList)
{
doc.Print();
}
I know Polymorphism is much sophisticated way of implementing it but can we really do the same using switch statement as well? I had a long argument with a fellow on it and he says it's possible. Is it?