commit 73a14819939ad815ee418c5695b82c3703ee92a3 Author: FengJungle Date: Thu Oct 17 21:55:01 2019 +0800 Initial version diff --git a/1.SimpleFactory/1.Picture/简单工厂.png b/1.SimpleFactory/1.Picture/简单工厂.png new file mode 100644 index 0000000..ade5391 Binary files /dev/null and b/1.SimpleFactory/1.Picture/简单工厂.png differ diff --git a/1.SimpleFactory/1.Picture/简单工厂模式.png b/1.SimpleFactory/1.Picture/简单工厂模式.png new file mode 100644 index 0000000..002a77c Binary files /dev/null and b/1.SimpleFactory/1.Picture/简单工厂模式.png differ diff --git a/1.SimpleFactory/1.Picture/简单工厂模式.vsdx b/1.SimpleFactory/1.Picture/简单工厂模式.vsdx new file mode 100644 index 0000000..9efd47a Binary files /dev/null and b/1.SimpleFactory/1.Picture/简单工厂模式.vsdx differ diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/Debug/SimpleFactoryPattern.exe b/1.SimpleFactory/2.Code/SimpleFactoryPattern/Debug/SimpleFactoryPattern.exe new file mode 100644 index 0000000..6a5c4d2 Binary files /dev/null and b/1.SimpleFactory/2.Code/SimpleFactoryPattern/Debug/SimpleFactoryPattern.exe differ diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/Debug/SimpleFactoryPattern.ilk b/1.SimpleFactory/2.Code/SimpleFactoryPattern/Debug/SimpleFactoryPattern.ilk new file mode 100644 index 0000000..068cc09 Binary files /dev/null and b/1.SimpleFactory/2.Code/SimpleFactoryPattern/Debug/SimpleFactoryPattern.ilk differ diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/Debug/SimpleFactoryPattern.pdb b/1.SimpleFactory/2.Code/SimpleFactoryPattern/Debug/SimpleFactoryPattern.pdb new file mode 100644 index 0000000..1525935 Binary files /dev/null and b/1.SimpleFactory/2.Code/SimpleFactoryPattern/Debug/SimpleFactoryPattern.pdb differ diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern.sdf b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern.sdf new file mode 100644 index 0000000..15cc4b9 Binary files /dev/null and b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern.sdf differ diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern.sln b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern.sln new file mode 100644 index 0000000..bcb8c8c --- /dev/null +++ b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleFactoryPattern", "SimpleFactoryPattern\SimpleFactoryPattern.vcxproj", "{35201E6A-CB1C-44B8-84FF-2112D2F2D6EC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {35201E6A-CB1C-44B8-84FF-2112D2F2D6EC}.Debug|Win32.ActiveCfg = Debug|Win32 + {35201E6A-CB1C-44B8-84FF-2112D2F2D6EC}.Debug|Win32.Build.0 = Debug|Win32 + {35201E6A-CB1C-44B8-84FF-2112D2F2D6EC}.Release|Win32.ActiveCfg = Release|Win32 + {35201E6A-CB1C-44B8-84FF-2112D2F2D6EC}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern.v12.suo b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern.v12.suo new file mode 100644 index 0000000..92574e2 Binary files /dev/null and b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern.v12.suo differ diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/CL.read.1.tlog b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/CL.read.1.tlog new file mode 100644 index 0000000..3b5f163 Binary files /dev/null and b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/CL.read.1.tlog differ diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/CL.write.1.tlog b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/CL.write.1.tlog new file mode 100644 index 0000000..a40c82d Binary files /dev/null and b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/CL.write.1.tlog differ diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/SimpleFactoryPattern.lastbuildstate b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/SimpleFactoryPattern.lastbuildstate new file mode 100644 index 0000000..2ac3da6 --- /dev/null +++ b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/SimpleFactoryPattern.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v120:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit +Debug|Win32|G:\8.New_cd\3.Study\8.Design Pattern\1.SimpleFactory\2.Code\SimpleFactoryPattern\| diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/cl.command.1.tlog b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/cl.command.1.tlog new file mode 100644 index 0000000..96771cc Binary files /dev/null and b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/cl.command.1.tlog differ diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/link.command.1.tlog b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/link.command.1.tlog new file mode 100644 index 0000000..7c7ea32 Binary files /dev/null and b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/link.command.1.tlog differ diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/link.read.1.tlog b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/link.read.1.tlog new file mode 100644 index 0000000..d1d2295 Binary files /dev/null and b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/link.read.1.tlog differ diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/link.write.1.tlog b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/link.write.1.tlog new file mode 100644 index 0000000..f1360a5 Binary files /dev/null and b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFa.35201E6A.tlog/link.write.1.tlog differ diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFactoryPattern.log b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFactoryPattern.log new file mode 100644 index 0000000..04b5a57 --- /dev/null +++ b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/SimpleFactoryPattern.log @@ -0,0 +1,13 @@ +生成启动时间为 2019/10/17 21:34:36。 + 1>项目“G:\8.New_cd\3.Study\8.Design Pattern\1.SimpleFactory\2.Code\SimpleFactoryPattern\SimpleFactoryPattern\SimpleFactoryPattern.vcxproj”在节点 2 上(Build 个目标)。 + 1>ClCompile: + E:\Microsoft Visual Studio 12.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _LIB /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TP /analyze- /errorReport:prompt main.cpp + main.cpp + Link: + E:\Microsoft Visual Studio 12.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"G:\8.New_cd\3.Study\8.Design Pattern\1.SimpleFactory\2.Code\SimpleFactoryPattern\Debug\SimpleFactoryPattern.exe" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"G:\8.New_cd\3.Study\8.Design Pattern\1.SimpleFactory\2.Code\SimpleFactoryPattern\Debug\SimpleFactoryPattern.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"G:\8.New_cd\3.Study\8.Design Pattern\1.SimpleFactory\2.Code\SimpleFactoryPattern\Debug\SimpleFactoryPattern.lib" /MACHINE:X86 Debug\main.obj + SimpleFactoryPattern.vcxproj -> G:\8.New_cd\3.Study\8.Design Pattern\1.SimpleFactory\2.Code\SimpleFactoryPattern\Debug\SimpleFactoryPattern.exe + 1>已完成生成项目“G:\8.New_cd\3.Study\8.Design Pattern\1.SimpleFactory\2.Code\SimpleFactoryPattern\SimpleFactoryPattern\SimpleFactoryPattern.vcxproj”(Build 个目标)的操作。 + +生成成功。 + +已用时间 00:00:00.98 diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/main.obj b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/main.obj new file mode 100644 index 0000000..666c774 Binary files /dev/null and b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/main.obj differ diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/vc120.idb b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/vc120.idb new file mode 100644 index 0000000..bd119d4 Binary files /dev/null and b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/vc120.idb differ diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/vc120.pdb b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/vc120.pdb new file mode 100644 index 0000000..383e1e1 Binary files /dev/null and b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/Debug/vc120.pdb differ diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/SimpleFactory.h b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/SimpleFactory.h new file mode 100644 index 0000000..bdb48eb --- /dev/null +++ b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/SimpleFactory.h @@ -0,0 +1,91 @@ +#ifndef __SIMPLE_FACTORY__ +#define __SIMPLE_FACTORY__ + +#include +#include +using namespace std; + +//ƷAbstractProduct +class AbstractSportProduct +{ +public: + AbstractSportProduct(){ + + } + //󷽷 + void printName(){}; + void play(){}; +}; + +//ƷBasketball +class Basketball :public AbstractSportProduct +{ +public: + Basketball(){ + printName(); + play(); + } + //ʵַ + void printName(){ + printf("Jungle get Basketball\n"); + } + void play(){ + printf("Jungle play Basketball\n"); + } +}; + +//ƷFootball +class Football :public AbstractSportProduct +{ +public: + Football(){ + printName(); + play(); + } + //ʵַ + void printName(){ + printf("Jungle get Football\n"); + } + void play(){ + printf("Jungle play Football\n"); + } +}; + +//ƷVolleyball +class Volleyball :public AbstractSportProduct +{ +public: + Volleyball(){ + printName(); + play(); + } + //ʵַ + void printName(){ + printf("Jungle get Volleyball\n"); + } + void play(){ + printf("Jungle play Volleyball\n"); + } +}; + +class Factory +{ +public: + AbstractSportProduct *getSportProduct(string productName) + { + AbstractSportProduct *pro = NULL; + if (productName == "Basketball"){ + pro = new Basketball(); + } + else if (productName == "Football"){ + pro = new Football(); + } + else if (productName == "Volleyball"){ + pro = new Volleyball(); + } + return pro; + } +}; + + +#endif //__SIMPLE_FACTORY__ \ No newline at end of file diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/SimpleFactoryPattern.vcxproj b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/SimpleFactoryPattern.vcxproj new file mode 100644 index 0000000..2b771d3 --- /dev/null +++ b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/SimpleFactoryPattern.vcxproj @@ -0,0 +1,87 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {35201E6A-CB1C-44B8-84FF-2112D2F2D6EC} + Win32Proj + SimpleFactoryPattern + + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + + + + + + \ No newline at end of file diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/SimpleFactoryPattern.vcxproj.filters b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/SimpleFactoryPattern.vcxproj.filters new file mode 100644 index 0000000..f72d572 --- /dev/null +++ b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/SimpleFactoryPattern.vcxproj.filters @@ -0,0 +1,27 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + + + 源文件 + + + \ No newline at end of file diff --git a/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/main.cpp b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/main.cpp new file mode 100644 index 0000000..6a3837f --- /dev/null +++ b/1.SimpleFactory/2.Code/SimpleFactoryPattern/SimpleFactoryPattern/main.cpp @@ -0,0 +1,20 @@ +#include +#include "SimpleFactory.h" + +int main() +{ + printf("򵥹ģʽ\n"); + + //幤 + Factory *fac = new Factory(); + AbstractSportProduct *product = NULL; + + product = fac->getSportProduct("Basketball"); + + product = fac->getSportProduct("Football"); + + product = fac->getSportProduct("Volleyball"); + + system("pause"); + return 0; +} \ No newline at end of file