Exemplo n.º 1
0
 @Override
 public void sum(Vector v) throws IncompatibleVectorSizesException {
   if (v.getSize() != adaptee.size()) {
     throw new IncompatibleVectorSizesException();
   }
   for (int i = 0; i < adaptee.size(); i++) {
     setElement(i, getElement(i) * v.getElement(i));
   }
 }
Exemplo n.º 2
0
 public boolean equals(Object obj) {
   if (obj instanceof Vector) {
     if (((Vector) obj).getSize() != adaptee.size()) {
       return false;
     }
     for (int i = 0; i < adaptee.size(); i++) {
       if (!(((Vector) obj).getElement(i) == getElement(i))) return false;
     }
   }
   return true;
 }
Exemplo n.º 3
0
  @Override
  public void mult(double a) {

    for (int i = 0; i < adaptee.size(); i++) {
      setElement(i, getElement(i) * a);
    }
  }
Exemplo n.º 4
0
 public String toString() {
   StringBuilder stringBuilder = new StringBuilder();
   for (int i = 0; i < adaptee.size(); i++) {
     stringBuilder.append(getElement(i));
     stringBuilder.append(" ");
   }
   return stringBuilder.toString().trim();
 }