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..a56cb43 --- /dev/null +++ b/Flyweight/Python/.idea/workspace.xml @@ -0,0 +1,402 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..560aae3 --- /dev/null +++ b/Flyweight/Python/FlyWeight.py @@ -0,0 +1,55 @@ +# -*- coding: utf8 -*- +from abc import ABCMeta, abstractmethod + +class Shap: + __metaclass__ = ABCMeta + @abstractmethod + def Draw(self,x,y): + pass + +class Point(Shap): + def Draw(self,x,y): + print "Точка" + +class Circle(Shap): + r = 10 + def Draw(self,x,y): + print "Круг" + +class Square(Shap): + a = 5 + def Draw(self,x,y): + print "Квадрат" + +class ShapeFactory: + def __init__(self): + self.shapes = {} + + def getShape(self, NameShape): + ShapOne = None + if (NameShape in self.shapes): + ShapOne = self.shapes[NameShape] + else: + if(NameShape == "Точка"): + ShapOne = Point() + elif(NameShape == "Круг"): + ShapOne = Circle() + elif(NameShape == "Квадрат"): + ShapOne = Square() + self.shapes[NameShape] = ShapOne + return ShapOne + +if __name__ == '__main__': + Shape = ShapeFactory() + listShape =[] + + listShape.append(Shape.getShape("Круг")) + listShape.append(Shape.getShape("Квадрат")) + listShape.append(Shape.getShape("Точка")) + listShape.append(Shape.getShape("Круг")) + listShape.append(Shape.getShape("Квадрат")) + listShape.append(Shape.getShape("Круг")) + listShape.append(Shape.getShape("Точка")) + + for ShapeIttem in listShape: + ShapeIttem.Draw(1,1) \ No newline at end of file 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..5ead8d4 --- /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 0000000..df298e4 Binary files /dev/null and b/Flyweight/java/out/production/java/com/Louco/Circle.class differ 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 0000000..c4df49b Binary files /dev/null and b/Flyweight/java/out/production/java/com/Louco/Main.class differ 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 0000000..2b21ca7 Binary files /dev/null and b/Flyweight/java/out/production/java/com/Louco/Point.class differ diff --git a/Flyweight/java/out/production/java/com/Louco/Shape.class b/Flyweight/java/out/production/java/com/Louco/Shape.class new file mode 100644 index 0000000..9c6b21b Binary files /dev/null and b/Flyweight/java/out/production/java/com/Louco/Shape.class differ 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 0000000..a53d261 Binary files /dev/null and b/Flyweight/java/out/production/java/com/Louco/ShapeFactory.class differ 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 0000000..5cdd02a Binary files /dev/null and b/Flyweight/java/out/production/java/com/Louco/Square.class differ diff --git a/Flyweight/java/src/com/Louco/Main.java b/Flyweight/java/src/com/Louco/Main.java new file mode 100644 index 0000000..71d14b4 --- /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{ + public void draw(int x, int y){ + System.out.println("Точка"); + } +} + +class Circle implements Shape{ + int r = 5; + public void draw(int x, int y){ + System.out.println("Круг"); + } +} + +class Square implements Shape{ + int a = 5; + 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; + } +} + +