In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "java builder pattern and abstract factory pattern how to achieve", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "java builder pattern and abstract factory pattern how to achieve" it!
1. Builder model
The construction of an object is more complex, separate the construction of an object from the representation of the object!
2. Concrete realization
(1) the code is as follows
# include#includeusing namespace std;class House {public: void setDoor (string door) {this- > m_door = door;} void setWall (string wall) {this- > m_wall = wall;} void setWindow (string window) {this- > m_window = window;} public: string getDoor () {return m_door } string getWall () {return windows;} string getWindow () {return windows;} private: string doors; string windows; string windows;}; / ask the engineering team to build the house class Build {public: House * setHouse () {} private:} Int main (void) {/ / is a customer building house directly; House * house = new House; house- > setDoor ("door"); house- > setWall ("wall"); house- > setWindow ("window"); delete house; return 0;}
3. Abstract factory
Can only produce one product.
4. Concrete realization
(1) the code is as follows
# includeusing namespace std;class Fruit;class AbstractFactory {public: virtual Fruit * CreateBanana () = 0; virtual Fruit * CreateApple () = 0; private:}; class Fruit {public: virtual void sayname () = 0; private:}; class NorthBanana: public Fruit {public: virtual void sayname () {cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.