My FactoryMethod in C #

Source: Internet
Author: User
Myfactorymethod
Using System;
Using System.Collections;
Singlepage Class,which Build the in 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) {}

}
};





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.