Skip to content
Snippets Groups Projects

Tanguy

Open tanguy.dietrich requested to merge david.carballo/poo2019numeric:Tanguy into master
2 files
+ 21
7
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -7,11 +7,12 @@ import java.util.function.Function;
@@ -7,11 +7,12 @@ import java.util.function.Function;
final public class Vector {
final public class Vector {
private static List<Double> lstVector;// = new ArrayList<Double>();
private List<Double> lstVector;// = new ArrayList<Double>();
private Vector() {
private Vector() {
this.lstVector=new ArrayList<Double>();
this.lstVector=new ArrayList<Double>();
}
}
 
private Vector(Double... elements) {
private Vector(Double... elements) {
this.lstVector=new ArrayList<Double>();
this.lstVector=new ArrayList<Double>();
for(double e:elements)
for(double e:elements)
@@ -36,6 +37,8 @@ final public class Vector {
@@ -36,6 +37,8 @@ final public class Vector {
public int len() {
public int len() {
throw new UnsupportedOperationException("This feature isn't implemented yet");
throw new UnsupportedOperationException("This feature isn't implemented yet");
}
}
 
//assertEquals(v1.toString(), "Vector[1.0, 2.0, 3.0]");
 
//assertEquals(v1.add(v2),v3);
public double get(int i) {
public double get(int i) {
throw new UnsupportedOperationException("This feature isn't implemented yet");
throw new UnsupportedOperationException("This feature isn't implemented yet");
@@ -46,11 +49,12 @@ final public class Vector {
@@ -46,11 +49,12 @@ final public class Vector {
public Vector add(Vector that) {
public Vector add(Vector that) {
//throw new UnsupportedOperationException("This feature isn't implemented yet");
//throw new UnsupportedOperationException("This feature isn't implemented yet");
for(double e:that.lstVector)
Vector v = new Vector();
 
for(int i=0;i<this.lstVector.size();i++)//a ameliorer avec for(e:element)
{
{
this.lstVector.add(e);
v.lstVector.add(Double.sum(this.lstVector.get(i),that.lstVector.get(i)));
}
}
return this;
return v;
}
}
public Vector mul(double m) {
public Vector mul(double m) {
@@ -151,7 +155,14 @@ final public class Vector {
@@ -151,7 +155,14 @@ final public class Vector {
// Apply formatting to the string if necessary
// Apply formatting to the string if necessary
strings.add(d.toString());
strings.add(d.toString());
}
}
return "Vector"+String.valueOf(strings);
if(this instanceof Vector)
 
{
 
return "Vector"+String.valueOf(strings);
 
}
 
else
 
{
 
return "Transposed"+String.valueOf(strings);
 
}
//throw new UnsupportedOperationException("This feature isn't implemented yet");
//throw new UnsupportedOperationException("This feature isn't implemented yet");
}
}
Loading