Person
using System;
class APerson {
virtual public string WashDishes(){
return "wet and dry";
}
}
class AMan:APerson{
override public string WashDishes(){
return "dry";}
}
class AWoman:APerson{
override public string WashDishes(){
return "wet";}
}
public class Program
{
static string result;
static void ViewModel(){
Model();
View();
}
static void View(){
Console.WriteLine (result);
}
static void Model(){
APerson Ivan = new AMan();
APerson Ira = new AWoman();
APerson[] family = new APerson[2];
family[0] = Ira;
family[1] = Ivan;
for (int i=0; i < 2; i++){
result+= family[i].WashDishes()+ " \n \r";
}
}
public static void Main()
{
ViewModel();
}
}
Pet
using System;
class APet {
public virtual string Say(){
return "I am a pet, not an animal";
}
}
class ADog:APet{
internal override string Say(){
return "Woof";}
}
class ACat:APet{
internal override string Say(){
return "Miow";}
}
class ARooster:APet{
internal override string Say(){
return "Cock-a-doodle-doo";}
}
class ADonkey:APet{
internal override string Say(){
return "Hee-haw";}
}
public class BremerStadtMus
{
static string[] aresult = {"","","",""};
static void Main(){
ModelView();
}
static void View(){
foreach(string s in aresult)
Console.WriteLine(s);
}
static void ModelView(){
Console.WriteLine("ModelView");
Model();
View();
}
static string Model(){
APet[]ap = new APet[4];
ap[0] = new ADog();
ap[1] = new ACat();
ap[2] = new ARooster();
ap[3] = new ADonkey();
string result="";
int j =0;
for (int i=0;i)}}