Пример #1
0
    //constructor for a PHOTO
    public Command(Cmdtype type)
    {
        if (type != Cmdtype.PHOTO)
        {
            throw new ArgumentException("You can only instance PHOTO without parameters", nameof(type));
        }

        Type = type;
    }
Пример #2
0
    //constructor for a led
    public Command(Cmdtype type, int value)
    {
        if (type == Cmdtype.PHOTO)
        {
            throw new ArgumentException("You can't instance a PHOTO with parameters", nameof(type));
        }
        if (type == Cmdtype.TIME && (value < 0 || value > 999))
        {
            throw new ArgumentException("Wrong value of TIME", nameof(value));
        }
        if ((type == Cmdtype.VISIBLE || type == Cmdtype.INFRARED || type == Cmdtype.ULTRAVIOLET) &&
            (value < 1 || value > 50))
        {
            throw new ArgumentException("Wrong number of led", nameof(value));
        }

        Type  = type;
        Value = value;
    }