zoukankan      html  css  js  c++  java
  • compositephotolibrary.cs

      using System;
      using System.Collections.Generic;
      using System.IO;
      using CompositePattern;

      //  Composite Pattern    Judith Bishop August 2007
      //  The pattern is generic, and an example is given for a real world client
     
      // The Client
      class CompositePatternExample {
        static void Main () {
          IComponent <string> album = new Composite<string> ("Album");
          IComponent <string> point = album;
          string [] s;
          string command, parameter;
          // Create and manipulate a structure
          StreamReader instream = new StreamReader("composite.dat");
          do {
            string t= instream.ReadLine();
            Console.WriteLine("\t\t\t\t"+t);
            s = t.Split();
            command = s[0];
            if (s.Length>1) parameter = s[1]; else parameter = null;
            switch (command) {
              case "AddSet"   :   
                IComponent <string> c = new Composite <string> (parameter);
                point.Add(c);
                point = c;
                break;
              case "AddPhoto":  point.Add(new Component <string> (parameter)); break;
              case "Remove"   : point = point.Remove(parameter); break;
              case "Find"        : point = album.Find(parameter);  break;
              case "Display"    : Console.WriteLine(album.Display(0));  break;
              case "Quit"        : break;
            }

          } while (!command.Equals("Quit"));
        }
      }
     


  • 相关阅读:
    c# 泛型总结
    透过字节码分析java基本类型数组的内存分配方式。
    c#索引器
    redis在asp.net 中的应用
    Unity3D shaderLab
    Unity3d Asset Store 打不开
    C# 类型转换的开销
    [转]权重算法
    Coroutine的原理以及实现
    在Unity3D里使用WinForm
  • 原文地址:https://www.cnblogs.com/shihao/p/2496301.html
Copyright © 2011-2022 走看看