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"));
        }
      }
     


  • 相关阅读:
    Fedora 18 Beta 天高地厚
    Action script 天高地厚
    DLL动态连接库 天高地厚
    VC下Debug和Release区别
    如何解决"应用程序无法启动,因为应用程序的并行配置不正确"问题
    GetWindowLong (hwnd, 0)
    windows文件关联、打开方式列表之修改注册表攻略
    小游戏开发流程
    常用CHM帮助文档集锦下载
    关于jsp页面传递中文参数乱码的解决
  • 原文地址:https://www.cnblogs.com/shihao/p/2496301.html
Copyright © 2011-2022 走看看