private void AddStoreCommandTask() { Console.Write("請輸入新商店 ID(輸入cancel取消): "); int storeID = 0; string inputString = Console.ReadLine(); if (inputString != "cancel") { while (inputString != "cancel" && (!int.TryParse(inputString, out storeID) || editingFactory.ContainsStore(storeID))) { if (editingFactory.ContainsStore(storeID)) { Console.Write("ID已存在 請輸入新商店 ID(整數)(輸入cancel取消): "); } else { Console.Write("不合法的輸入 請輸入新商店 ID(整數)(輸入cancel取消): "); } inputString = Console.ReadLine(); } if (inputString != "cancel") { Console.Write("請輸入商店名稱: "); string storeName = Console.ReadLine(); editingFactory.AddStore(new Store(storeID, storeName)); ViewCommandTask(); } } }