コード例 #1
0
        public AquariumType LookupFromName(AquariumType type)
        {
            if (type != null && type.Id == 0 && type.Name != null)
            {
                AquariumTypes lookupType = (AquariumTypes)Enum.Parse(typeof(AquariumTypes), type.Name);

                type = new AquariumType
                {
                    Id   = (int)lookupType,
                    Name = lookupType.ToString()
                };
            }

            return(type);
        }
コード例 #2
0
ファイル: Aquarium.cs プロジェクト: PavelSheglov/lab_2
        public Aquarium(AquariumType aquariumType) : base()
        {
            _aquariumType = aquariumType;
            switch (aquariumType)
            {
            case AquariumType.Freshwater:
                _volume       = 2.00;
                this.Capacity = 5;
                break;

            case AquariumType.SeaWater:
                _volume       = 2.00;
                this.Capacity = 5;
                break;
            }
        }
コード例 #3
0
ファイル: Aquarium.cs プロジェクト: PavelSheglov/lab_2
 public Aquarium(AquariumType aquariumType, double volume, byte capacity) : base()
 {
     try
     {
         if (volume <= 0 || capacity == 0)
         {
             throw new ArgumentException("Недопустимые значения объема и/или емкости!!!");
         }
         _aquariumType = aquariumType;
         _volume       = volume;
         this.Capacity = capacity;
     }
     catch (ArgumentException)
     {
         throw;
     }
 }