コード例 #1
0
        public static NullMobile GetInstance()
        {
            if (_instance == null)
            {
                _instance = new NullMobile();
            }

            return(_instance);
        }
コード例 #2
0
 public IMobile GetPhoneByCompany(string mobilePhone)
 {
     if (mobilePhone.ToLower() == "sony")
     {
         return(new SonyMobile());
     }
     else if (mobilePhone.ToLower() == "samsung")
     {
         return(new SamsungMobile());
     }
     else
     {
         return(NullMobile.GetInstance());
     }
 }