示例#1
0
        void Test()
        {
            AbstractFactory<string, IClothes> factory = new ClothesFactory();

            var ubranie1 = factory.GetProduct("Dress");
            var ubranie2 = factory.GetProduct("Trousers");
            var ubranie3 = factory.GetProduct("Shirt");
        }
示例#2
0
  public void ButtonPressed(Button button)
  {
      option = button.name;
      Debug.Log(option);

      switch (option)
      {
      case ("Beach"):
          requirements.Location = 1;
          break;

      case ("Venue"):
          requirements.Location = 2;
          break;

      case ("Office"):
          requirements.Location = 3;
          break;

      case ("House"):
          requirements.Location = 4;
          break;

      case ("Woman"):
          requirements.Woman = true;
          break;

      case ("Man"):
          requirements.Woman = false;
          break;

      case ("Formal"):
          requirements.Formal = true;
          break;

      case ("Informal"):
          requirements.Formal = false;
          break;

      case ("Create"):
          ClothesFactory factory = new ClothesFactory(requirements);
          IClothes       v       = factory.Create();
          createPressed(v);
          break;

      default:
          requirements.Location = 2;
          requirements.Woman    = true;
          requirements.Formal   = false;
          break;
      }

      //return 0;
  }
示例#3
0
    void Start()
    {
        ClothesRequirements requirements = new ClothesRequirements();

        requirements.Woman    = Woman;
        requirements.Location = Mathf.Max(Location);
        requirements.Woman    = Formal;
        requirements.Formal   = Formal;

        ClothesFactory factory = new ClothesFactory(requirements);
        IClothes       v       = factory.Create();

        Debug.Log(v);
    }
示例#4
0
        static void Main(string[] args)
        {
            try
            {
                ClothesFactory clothesFactory = new ClothesFactory();
                IClothes       shirt          = null;
                // User make choice.

                Console.WriteLine("Please choose clothing you want to trading:");
                Console.WriteLine("1: TShirt, 2: DShirt");

                switch (int.Parse(Console.ReadLine().ToString()))
                {
                case 1:
                    shirt = clothesFactory.GetClothes(ClothesType.TShirt);
                    break;

                case 2:
                    shirt = clothesFactory.GetClothes(ClothesType.TShirt);
                    break;

                default:

                    break;
                }

                // Execute action.
                Console.WriteLine("Please choose action you want to trading:");
                Console.WriteLine("1: Sell, 2: Buy");
                var tradetype = int.Parse(Console.ReadLine().ToString());

                // User make a number to trade.
                Console.WriteLine("Please choose number of item you want to trading:");
                var tradeNo = int.Parse(Console.ReadLine().ToString());

                // User make a number to trade.
                Console.WriteLine("Please choose option for item you want to trading:");
                var opts = OptionUtility.GetOption(shirt.Options);

                switch (tradetype)
                {
                case 1:
                    Console.WriteLine(shirt.Trade(TradeType.Sell, tradeNo, opts));
                    break;

                case 2:
                    Console.WriteLine(shirt.Trade(TradeType.Buy, tradeNo, opts));
                    break;

                default:

                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            Console.Read();
        }