interface Ciało { K zero(); K dodaj (K a, K b); K mnóż (K a, K b); } public class CiałoDouble implements Ciało { @Override public Double zero() { return 0.0; } @Override public Double dodaj(Double a, Double b) { return a+b; } @Override public Double mnóż(Double a, Double b) { return a*b; } } public class Main { public static void main (String[] args) { CiałoDouble f = new CiałoDouble(); Wektor v = new Wektor(f, new Double[]{1.0, 2.0}); v.przemnóżPrzezSkalar(3.0); } } import java.lang.reflect.Array; import java.util.Arrays; import java.util.Objects; public class Wektor > { private K[] x; private F f; private void alokuj (int rozmiar, K... zbędne) { Class c = zbędne.getClass().getComponentType(); x = (K[]) Array.newInstance(c, rozmiar); } Wektor(F f) { this.f=f; alokuj(0);} Wektor(int n, F f) { this.f=f; alokuj(n); for (int i=0; i w) { this(w.f, w.x); } @Override public int hashCode() { //return x.hashCode(); return Arrays.hashCode(x); } @Override public boolean equals(Object obj) { if (!(obj instanceof Wektor )) return false; Wektor v = (Wektor) obj; if (v==null) return false; if (v.x.length != x.length) return false; for (int i=0; i