From bd3809b306d84243b5eeeaad8a4587a75235ed77 Mon Sep 17 00:00:00 2001 From: Louco Date: Mon, 27 Mar 2017 16:20:47 +0300 Subject: [PATCH 1/2] c# and java FlyWeight --- .gitattributes | 63 +++ .gitignore | 189 +++++++++ Flyweight/Python/.idea/Python.iml | 11 + Flyweight/Python/.idea/misc.xml | 14 + Flyweight/Python/.idea/modules.xml | 8 + Flyweight/Python/.idea/workspace.xml | 373 ++++++++++++++++++ Flyweight/Python/FlyWeight.py | 2 + Flyweight/c#/FlyWeight/FlyWeight.sln | 22 ++ Flyweight/c#/FlyWeight/FlyWeight/App.config | 6 + .../c#/FlyWeight/FlyWeight/FlyWeight.csproj | 58 +++ Flyweight/c#/FlyWeight/FlyWeight/Program.cs | 85 ++++ .../FlyWeight/Properties/AssemblyInfo.cs | 36 ++ Flyweight/java/.idea/compiler.xml | 22 ++ .../.idea/copyright/profiles_settings.xml | 3 + Flyweight/java/.idea/description.html | 1 + Flyweight/java/.idea/misc.xml | 12 + Flyweight/java/.idea/modules.xml | 8 + Flyweight/java/.idea/project-template.xml | 3 + Flyweight/java/.idea/workspace.xml | 222 +++++++++++ Flyweight/java/java.iml | 12 + .../production/java/com/Louco/Circle.class | Bin 0 -> 577 bytes .../out/production/java/com/Louco/Main.class | Bin 0 -> 1405 bytes .../out/production/java/com/Louco/Point.class | Bin 0 -> 576 bytes .../out/production/java/com/Louco/Shape.class | Bin 0 -> 123 bytes .../java/com/Louco/ShapeFactory.class | Bin 0 -> 1324 bytes .../production/java/com/Louco/Square.class | Bin 0 -> 551 bytes Flyweight/java/src/com/Louco/Main.java | 73 ++++ 27 files changed, 1223 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 Flyweight/Python/.idea/Python.iml create mode 100644 Flyweight/Python/.idea/misc.xml create mode 100644 Flyweight/Python/.idea/modules.xml create mode 100644 Flyweight/Python/.idea/workspace.xml create mode 100644 Flyweight/Python/FlyWeight.py create mode 100644 Flyweight/c#/FlyWeight/FlyWeight.sln create mode 100644 Flyweight/c#/FlyWeight/FlyWeight/App.config create mode 100644 Flyweight/c#/FlyWeight/FlyWeight/FlyWeight.csproj create mode 100644 Flyweight/c#/FlyWeight/FlyWeight/Program.cs create mode 100644 Flyweight/c#/FlyWeight/FlyWeight/Properties/AssemblyInfo.cs create mode 100644 Flyweight/java/.idea/compiler.xml create mode 100644 Flyweight/java/.idea/copyright/profiles_settings.xml create mode 100644 Flyweight/java/.idea/description.html create mode 100644 Flyweight/java/.idea/misc.xml create mode 100644 Flyweight/java/.idea/modules.xml create mode 100644 Flyweight/java/.idea/project-template.xml create mode 100644 Flyweight/java/.idea/workspace.xml create mode 100644 Flyweight/java/java.iml create mode 100644 Flyweight/java/out/production/java/com/Louco/Circle.class create mode 100644 Flyweight/java/out/production/java/com/Louco/Main.class create mode 100644 Flyweight/java/out/production/java/com/Louco/Point.class create mode 100644 Flyweight/java/out/production/java/com/Louco/Shape.class create mode 100644 Flyweight/java/out/production/java/com/Louco/ShapeFactory.class create mode 100644 Flyweight/java/out/production/java/com/Louco/Square.class create mode 100644 Flyweight/java/src/com/Louco/Main.java diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7964536 --- /dev/null +++ b/.gitignore @@ -0,0 +1,189 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +x64/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Roslyn cache directories +*.ide/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +#NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding addin-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +## TODO: Comment the next line if you want to checkin your +## web deploy settings but do note that will include unencrypted +## passwords +#*.pubxml + +# NuGet Packages Directory +packages/* +## TODO: If the tool you use requires repositories.config +## uncomment the next line +#!packages/repositories.config + +# Enable "build/" folder in the NuGet Packages folder since +# NuGet packages use it for MSBuild targets. +# This line needs to be after the ignore of the build folder +# (and the packages folder if the line above has been uncommented) +!packages/build/ + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml \ No newline at end of file diff --git a/Flyweight/Python/.idea/Python.iml b/Flyweight/Python/.idea/Python.iml new file mode 100644 index 0000000..6711606 --- /dev/null +++ b/Flyweight/Python/.idea/Python.iml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Flyweight/Python/.idea/misc.xml b/Flyweight/Python/.idea/misc.xml new file mode 100644 index 0000000..9eabf49 --- /dev/null +++ b/Flyweight/Python/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Flyweight/Python/.idea/modules.xml b/Flyweight/Python/.idea/modules.xml new file mode 100644 index 0000000..3097039 --- /dev/null +++ b/Flyweight/Python/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Flyweight/Python/.idea/workspace.xml b/Flyweight/Python/.idea/workspace.xml new file mode 100644 index 0000000..523db23 --- /dev/null +++ b/Flyweight/Python/.idea/workspace.xml @@ -0,0 +1,373 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1490620183072 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Flyweight/Python/FlyWeight.py b/Flyweight/Python/FlyWeight.py new file mode 100644 index 0000000..28069c6 --- /dev/null +++ b/Flyweight/Python/FlyWeight.py @@ -0,0 +1,2 @@ +# -*- coding: utf8 -*- + diff --git a/Flyweight/c#/FlyWeight/FlyWeight.sln b/Flyweight/c#/FlyWeight/FlyWeight.sln new file mode 100644 index 0000000..5306b99 --- /dev/null +++ b/Flyweight/c#/FlyWeight/FlyWeight.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.40629.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlyWeight", "FlyWeight\FlyWeight.csproj", "{2CA919CC-DF95-4CEC-A10A-CCCD9793F688}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2CA919CC-DF95-4CEC-A10A-CCCD9793F688}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2CA919CC-DF95-4CEC-A10A-CCCD9793F688}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2CA919CC-DF95-4CEC-A10A-CCCD9793F688}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2CA919CC-DF95-4CEC-A10A-CCCD9793F688}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Flyweight/c#/FlyWeight/FlyWeight/App.config b/Flyweight/c#/FlyWeight/FlyWeight/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Flyweight/c#/FlyWeight/FlyWeight/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Flyweight/c#/FlyWeight/FlyWeight/FlyWeight.csproj b/Flyweight/c#/FlyWeight/FlyWeight/FlyWeight.csproj new file mode 100644 index 0000000..9d26d7c --- /dev/null +++ b/Flyweight/c#/FlyWeight/FlyWeight/FlyWeight.csproj @@ -0,0 +1,58 @@ + + + + + Debug + AnyCPU + {2CA919CC-DF95-4CEC-A10A-CCCD9793F688} + Exe + Properties + FlyWeight + FlyWeight + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Flyweight/c#/FlyWeight/FlyWeight/Program.cs b/Flyweight/c#/FlyWeight/FlyWeight/Program.cs new file mode 100644 index 0000000..2fbaaad --- /dev/null +++ b/Flyweight/c#/FlyWeight/FlyWeight/Program.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlyWeight +{ + class Program + { + static void Main(string[] args) + { + ShapeFactory shapeFactory = new ShapeFactory(); + List shapes = new List(); + shapes.Add(shapeFactory.getShape("Круг")); + shapes.Add(shapeFactory.getShape("Квадрат")); + shapes.Add(shapeFactory.getShape("Круг")); + shapes.Add(shapeFactory.getShape("Круг")); + shapes.Add(shapeFactory.getShape("Точка")); + shapes.Add(shapeFactory.getShape("Точка")); + shapes.Add(shapeFactory.getShape("Квадрат")); + + foreach (Shape shape in shapes){ + int x = 1; + int y = 2; + shape.Draw(x,y); + } + Console.ReadLine(); + } + } +} + +interface Shape { + void Draw(int x, int y); +} + + +class Point : Shape { + public void Draw(int x, int y) { + Console.WriteLine("Точка"); + } +} + +class Circle : Shape { + int r = 10; + public void Draw(int x, int y) + { + Console.WriteLine("Круг"); + } +} + +class Square : Shape { + int a = 10; + public void Draw(int x, int y) + { + Console.WriteLine("Квадрат"); + } +} + +class ShapeFactory { + private static SortedDictionary shapes = new SortedDictionary(); + + public Shape getShape(string NameShape) { + Shape shape; + shapes.TryGetValue(NameShape , out shape); + if (shape == null) { + switch (NameShape) { + case "Точка": + shape = new Point(); + break; + case "Круг": + shape = new Circle(); + break; + case "Квадрат": + shape = new Square(); + break; + } + shapes.Add(NameShape,shape); + } + return shape; + } + + + +} diff --git a/Flyweight/c#/FlyWeight/FlyWeight/Properties/AssemblyInfo.cs b/Flyweight/c#/FlyWeight/FlyWeight/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..af0fb79 --- /dev/null +++ b/Flyweight/c#/FlyWeight/FlyWeight/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Управление общими сведениями о сборке осуществляется с помощью +// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения, +// связанные со сборкой. +[assembly: AssemblyTitle("FlyWeight")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("FlyWeight")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Параметр ComVisible со значением FALSE делает типы в сборке невидимыми +// для COM-компонентов. Если требуется обратиться к типу в этой сборке через +// COM, задайте атрибуту ComVisible значение TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("6337113b-afa7-424f-88ba-d1ea9ac9b5b3")] + +// Сведения о версии сборки состоят из следующих четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Flyweight/java/.idea/compiler.xml b/Flyweight/java/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/Flyweight/java/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Flyweight/java/.idea/copyright/profiles_settings.xml b/Flyweight/java/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/Flyweight/java/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Flyweight/java/.idea/description.html b/Flyweight/java/.idea/description.html new file mode 100644 index 0000000..db5f129 --- /dev/null +++ b/Flyweight/java/.idea/description.html @@ -0,0 +1 @@ +Simple Java application that includes a class with main() method \ No newline at end of file diff --git a/Flyweight/java/.idea/misc.xml b/Flyweight/java/.idea/misc.xml new file mode 100644 index 0000000..e29b6f0 --- /dev/null +++ b/Flyweight/java/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Flyweight/java/.idea/modules.xml b/Flyweight/java/.idea/modules.xml new file mode 100644 index 0000000..3f8f820 --- /dev/null +++ b/Flyweight/java/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Flyweight/java/.idea/project-template.xml b/Flyweight/java/.idea/project-template.xml new file mode 100644 index 0000000..1f08b88 --- /dev/null +++ b/Flyweight/java/.idea/project-template.xml @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/Flyweight/java/.idea/workspace.xml b/Flyweight/java/.idea/workspace.xml new file mode 100644 index 0000000..2fab8be --- /dev/null +++ b/Flyweight/java/.idea/workspace.xml @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1490608444572 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Flyweight/java/java.iml b/Flyweight/java/java.iml new file mode 100644 index 0000000..d5c0743 --- /dev/null +++ b/Flyweight/java/java.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/Flyweight/java/out/production/java/com/Louco/Circle.class b/Flyweight/java/out/production/java/com/Louco/Circle.class new file mode 100644 index 0000000000000000000000000000000000000000..df298e491bf613aa134819b067d98a0dbbf089c0 GIT binary patch literal 577 zcmZut$x6de6g{tv#-vf}Q0Jk}X%}YWMk;Oup%@26vWf);#;NKI zy;~v_$u>jYtTY&uo#@147_>#`9i&0ii;sEJCuG=;T<$k`EM(sWmE=rZ$~!j-EIUfw z$l4LH>w7hFI*Iu;LyuXnOJjCJb<3bTQ5w76u8^kMJ{RHoIltlt3NQ?4&{ZrNSi&+x zU+bZL*S>E(t5`9xiZzDf-$4XPx#jcl)H-aQdu~GMe^|~Lzo0?CNY3qL;svyCloGXM zXL1o)N3jSKCy6~CQ2LR7UDufOGf$ZIg#57bik`nF dCS|B(Cgl#XYa&yP(x6VhQZ|xdjI44P{|2?}Y=i&+ literal 0 HcmV?d00001 diff --git a/Flyweight/java/out/production/java/com/Louco/Main.class b/Flyweight/java/out/production/java/com/Louco/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..c4df49b0aabdbc6374967e06bd13c61e68cdb355 GIT binary patch literal 1405 zcmZ`(-%}G;7(F-HsfF$^Lb!B7MzC5EGjVL-c1#c&#D^zxm=h<2ZiA&zqrqY~!@ z!b6sAxx)g%RC-Fl7^#%X0Xnxmd}JDa+0hXMwvwGIc9|N8MGKd1cRL3a(?>vsqn7+~bquvmy{$np2A`(bfP{ z&@PRmoLN?A{{W1D=^q?bMYrM*XZOzYTM@#9{Y<}Aznx{*n$P5|C6}?Fqu6Pp)~6qs zPV8FqAHViH$POyL?4 z>oHAW8_^&4<>@=+B3o;z7pe7{s5^3Q*-;!H3CxxqpQyn8)CVrjdkS-Ms#Fr_Xw0tF z%%*P=(0YfROr;wJwq27Gl5=WlynK&M^7`|PVf)6e?feEFI$K9`HnWXXF3kxVB}e_p z3!KX3(o^^n?fil2PXKHSNv@yJ%5WFlLkHI(e)q$>xrS>_bn@NYdf$UCT21&ApV7m^ z!bK1f`krqhaAO_8{3Z07kL^a2IH_$9FXmlDI zXc71oefq6c;BUkSLw)hm3$z^zZ|$-()DiAr3yC0pd-GaTGoYyrqm^rf-zNUoL`f!w zgCuzz%{Yq|Tw(k++AxCzex_=VsM}*I_KcdXlD3xQ0wn$I_#AsF)ng)j!8ghLE-Jkb zA?7?sH+uX^Pq7~dC|Ml8;47p!ff<}cnpJ~1#0)KPE!N9eA3a?Nyn&67M88Bv;;_Wm R65jy-;s}$EFeQMaZvkH!KU)9* literal 0 HcmV?d00001 diff --git a/Flyweight/java/out/production/java/com/Louco/Point.class b/Flyweight/java/out/production/java/com/Louco/Point.class new file mode 100644 index 0000000000000000000000000000000000000000..2b21ca7058833c9120a631c81d7639384a741ab2 GIT binary patch literal 576 zcmZuu%TB^T6g>mgp|w5`-!H&tbzwIyOf+sxOo;W7VAv0}fgzX^fP1`7rjvBZ(*C~y=RSVUD~ z7~GeEj1L&n)@Fr4I}9&9hEYcb-f6p8^`Z+=^$8hwLRa_|5lPkeK`pM!D~7D&hE3ZE z+iqx|hcbxw$mlW>Hw*(-sib__EmeoXD2MIH^^T7a-LWjYzY+?ng zMD5;p-#_oVZ`}uuH52RDpkRL{F^nm_?TeshpH&;48~-Ae>!L-IevrzYtJrJOzG0iF zlTIR+6g;Bf8MXib literal 0 HcmV?d00001 diff --git a/Flyweight/java/out/production/java/com/Louco/ShapeFactory.class b/Flyweight/java/out/production/java/com/Louco/ShapeFactory.class new file mode 100644 index 0000000000000000000000000000000000000000..a53d261511b0675815df656af18e932db2398ed5 GIT binary patch literal 1324 zcmZuxOKTHR6#i~rlT0V6jkdnu+Gk?4*7!)Qk7})us1T_rxR{PZI+`YRnh5Sh1vi3A zu^YjSposN>qJ`p4=xVZb=@0M+xKY1*6HKigm^t^Hx#v6I`Rez?DF!oD36vlxt(i#rx(2>w^NQWWqVI46fWXcf@866!mnALDpAT%>+ zPTMmA?YZmbEi+ZCI;B+JoX!YD3Qnac*nw{Kh^FjBcju=bo&w$Ih3CT#bjIZZC(r>y{&rnpU;q-X?swXuGPI!0z7vDfKPSlufCA%jT4-s#;#!g+Nek5a?JTIa;Wi z)(xto7*c%=>@A$NO3gO)LZ#+f_NXJ9isVhFyhoNWupS!>bfQbcF$2eOf+8%_i%R<)2v z9M_UmmV^p7Yo==(7{wVj**fzvb7qpA33Rp6m9|Z}3DQ#Q{KR$JlBHUq#ux}hTaXIQ zU$nWgd+G5svNL^4POKSXtCQr>7!%ISS&ooR!X?f@=SmP)I9k&+7C5xR+yC)bD2Z+S zoYwI364)S5h;}VKAJ)N7%Y$QNBUdR}K^yG<2=PX3*~Di^1qZR2YooCNTdGR0{O&OJRLaaO9zr45PZqk$no}zAB$<)ec6olop#67-`{T0 z9#6(YAD}(KE`K`k99xp{uyQ*C(rr)1Bgzd0(}B*w3nuV7(lBfXkZgN+56(ls{1I*W z=jfV;!DW=owt2+3Y|l%EiBDMN$ECy^xBFFMKmRDe0Ys7J@8clu<1ii){t=GiF@`bA zseXnLyuxWE#Wtnh>!uWJ96PX+Vnn%X7j~0SH}Sd<`6YiuJsNsNEY`MJ*MCCO5k}u% e-FGVTkOVtOF#ZlcslHIO8tU(-*Uy*_1AhP(m@_f} literal 0 HcmV?d00001 diff --git a/Flyweight/java/out/production/java/com/Louco/Square.class b/Flyweight/java/out/production/java/com/Louco/Square.class new file mode 100644 index 0000000000000000000000000000000000000000..5cdd02a34122f4267aa46a5c95b271a614bfc23d GIT binary patch literal 551 zcmZut$x6de6g{s~OpI0QJl6@Th}pPP+z3Lk4p8a-H3s{nO=_Ar?8MLTD^x_mg&*K5 z{*ZW*3W~V6<2&cvcklb>>l=U#EE~vSRL2;`doW>O5>pzcHOy$3707KVR|VSw>C#F~ zAhYA0I0F3@;H9G*l;kv%Qv8@j~0Ps^_8folPp8 z`0`R9TPl}hVR1z()2;=Ksu%jUv#VlZeP1ef{Y+j+6Fty1%$X=+ULYUcMUT;a^z?BP z-GAI_STM1OC4qsz)7XmnR#UpC)?xk3u>-E~3)PTqPWlC^UUveg#ihNF(2+_)SDtm` zD>tYHz9U;)Vd$T>fYy#dO_#heQ;%Zn4p^QUOsij~34Vib(o)fb3| zCG+xeaN%o8W^CD$$Jz_GwP2>71Gbh{0JDyoOMpJ5|LsT_$@*T22n_a Obqp~}F(0N>3L{@225$cV literal 0 HcmV?d00001 diff --git a/Flyweight/java/src/com/Louco/Main.java b/Flyweight/java/src/com/Louco/Main.java new file mode 100644 index 0000000..e5dfdc6 --- /dev/null +++ b/Flyweight/java/src/com/Louco/Main.java @@ -0,0 +1,73 @@ +package com.Louco; + +import java.util.*; + +public class Main { + + public static void main(String[] args) { + ShapeFactory shapeFactory = new ShapeFactory(); + List shapes = new ArrayList<>(); + shapes.add(shapeFactory.gerShape("Круг")); + shapes.add(shapeFactory.gerShape("Точка")); + shapes.add(shapeFactory.gerShape("Точка")); + shapes.add(shapeFactory.gerShape("Квадрат")); + shapes.add(shapeFactory.gerShape("Точка")); + shapes.add(shapeFactory.gerShape("Круг")); + + Random ran = new Random(); + for (Shape shape: shapes){ + int x = ran.nextInt(100); + int y = ran.nextInt(100); + shape.draw(x,y); + } + } +} + +interface Shape{ + void draw(int x, int y); +} + +class Point implements Shape{ + int r = 5; + public void draw(int x, int y){ + System.out.println("Точка"); + } +} + +class Circle implements Shape{ + int a =10; + public void draw(int x, int y){ + System.out.println("Круг"); + } +} + +class Square implements Shape{ + public void draw(int x, int y){ + System.out.println("Квадрат"); + } +} + +class ShapeFactory{ + private static final Map shapes = new HashMap<>(); + public Shape gerShape(String shapename){ + Shape shape = shapes.get(shapename); + if(shape == null){ + switch (shapename){ + case "Точка": + shape = new Point(); + break; + + case "Круг": + shape = new Circle(); + break; + case "Квадрат": + shape = new Square(); + break; + } + shapes.put(shapename, shape); + } + return shape; + } +} + + From f725b563e2053a719b275f9969758ceb6d5ae894 Mon Sep 17 00:00:00 2001 From: Louco Date: Mon, 27 Mar 2017 16:57:30 +0300 Subject: [PATCH 2/2] Python flyweight --- Flyweight/Python/.idea/workspace.xml | 51 +++++++++++++++++++------ Flyweight/Python/FlyWeight.py | 53 ++++++++++++++++++++++++++ Flyweight/java/.idea/workspace.xml | 30 +++++++-------- Flyweight/java/src/com/Louco/Main.java | 4 +- 4 files changed, 110 insertions(+), 28 deletions(-) diff --git a/Flyweight/Python/.idea/workspace.xml b/Flyweight/Python/.idea/workspace.xml index 523db23..a56cb43 100644 --- a/Flyweight/Python/.idea/workspace.xml +++ b/Flyweight/Python/.idea/workspace.xml @@ -13,6 +13,9 @@