Exemplo n.º 1
0
        public static Polinome operator -(Polinome obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException();
            }
            Polinome polinome = new Polinome(obj.coefficient);

            for (int i = 0; i < obj.coefficient.Length; i++)
            {
                polinome.coefficient[i] *= -1;
            }
            return(polinome);
        }
Exemplo n.º 2
0
        public static Polinome operator+(Polinome obj1, Polinome obj2)
        {
            if (ReferenceEquals(obj1, null) || ReferenceEquals(obj2, null))
            {
                throw new ArgumentNullException();
            }

            int minLength = obj1.Degree.CompareTo(obj2.Degree) <= 0 ? obj1.Degree : obj2.Degree;

            Polinome resultObj = obj1.Degree.CompareTo(obj2.Degree) <= 0
                ? new Polinome(obj2.coefficient)
                : new Polinome(obj1.coefficient);

            for (int i = 0; i <= minLength; i++)
            {
                resultObj[i] += obj1.Degree.CompareTo(obj2.Degree) <= 0
                    ? obj1.coefficient[i]
                    : obj2.coefficient[i];
            }
            return(resultObj);
        }
Exemplo n.º 3
0
 public bool Equals(Polinome obj)
 {
     if (ReferenceEquals(this, obj) == true)
     {
         return(true);
     }
     if (ReferenceEquals(null, obj) == true)
     {
         return(false);
     }
     if (this.coefficient.Length != obj.coefficient.Length)
     {
         return(false);
     }
     for (int i = 0; i < obj.coefficient.Length; i++)
     {
         if (this.coefficient[i] != obj.coefficient[i])
         {
             return(false);
         }
     }
     return(true);
 }