I have trouble with my java homework. I am making a Matrice class and i have trouble with the shallow constructor that take another Matrice as argument.
Public class Matrice implements IMatrice{
private static int numLignes ;
private static int numColonnes ;
private static ArrayList<Double> elements ;
public Matrice(int numLignes, int numColonnes ) {
this.numColonnes = numColonnes ;
this.numLignes = numLignes ;
}
public Matrice(int numLignes, int numColonnes , double valeurs ){
this(numLignes,numColonnes);
this.elements = new ArrayList<>(numLignes * numColonnes);
for(int i = 0 ;i< numLignes * numColonnes;i++){
elements.add(valeurs);
}
}
public Matrice(int numLignes, int numColonnes , double[] elements ) {
this(numLignes,numColonnes);
this.elements = new ArrayList<>() ;
for(int i = 0 ;i<numLignes * numColonnes;i++){
this.elements.add(elements[i]);
}
}
public Matrice(Matrice autreMatrice) {
numColonnes = autreMatrice.getNumColonnes();
numLignes = autreMatrice.getNumLignes();
}
Is my shallow copy constructor is right ? Because when i run my teacher main test, its say im wrong. COuld be a error on my teacher main test, but i doubt it.
Thx !