欢迎光临
我们一直在努力

My FactoryMethod in C#-.NET教程,C#语言

建站超值云服务器,限时71元/月

//myfactorymethod

using system;

using system.collections;

//singlepage class,which build the at last product,part element

//—-top class

abstract class singlepage

{

};

//—-element1

class registerpage:singlepage

{

};

//—-element2

class loginpage:singlepage

{

};

//—-element3

class indexpage:singlepage

{

};

//—-element4

class titlepage:singlepage

{

};

//—-element5

class contentpage:singlepage

{

};

//—-element6

class postpage:singlepage

{

};

//—-element7

class replypage:singlepage

{

};

//———————————————-end of page class

//homepage class,factorymethod is in this class,creater

//—-top class

abstract class homepage

{

//fields,the aim page data

protected arraylist pages=new arraylist();

//properties

public arraylist pages

{

get{return pages;}

}

//methods

public homepage()

{

this.createhomepage();

}

abstract public void createhomepage();

};

//—-concreteclass1

class forum:homepage

{

override public void createhomepage()

{

pages.add(new registerpage());

pages.add(new loginpage());

pages.add(new indexpage());

pages.add(new titlepage());

pages.add(new contentpage());

pages.add(new postpage());

pages.add(new replypage());

}

};

//—-concreteclass2

class guestbook:homepage

{

override public void createhomepage()

{

pages.add(new registerpage());

pages.add(new loginpage());

pages.add(new contentpage());

pages.add(new replypage());

}

};

//———————————————-end of homepage class

//test

class testapp

{

public static void main(string[] args)

{

homepage aforum=new forum();

homepage aguestbook=new guestbook();

foreach(singlepage singlepage in aforum.pages)

{

console.writeline("in a forum homepage contians {0}",singlepage);

}

foreach(singlepage singlepage in aguestbook.pages)

{

console.writeline("in a guestbook homepage contians {0}",singlepage);

}

while(true){}

}

};

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » My FactoryMethod in C#-.NET教程,C#语言
分享到: 更多 (0)

相关推荐

  • 暂无文章