Skip to content
Snippets Groups Projects

Tanguy

Open tanguy.dietrich requested to merge david.carballo/poo2019numeric:Tanguy into master
2 files
+ 22
13
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -7,23 +7,24 @@ import java.util.function.Function;
@@ -7,23 +7,24 @@ import java.util.function.Function;
final public class Vector {
final public class Vector {
private static List<Double> lst;// = new ArrayList<Double>();
private static List<Double> lstVector;// = new ArrayList<Double>();
 
private Vector() {
private Vector() {
this.lst=new ArrayList<Double>();
this.lstVector=new ArrayList<Double>();
}
}
private Vector(Double... elements) {
private Vector(Double... elements) {
this.lst=new ArrayList<Double>();
this.lstVector=new ArrayList<Double>();
for(double e:elements)
for(double e:elements)
{
{
lst.add(e);
lstVector.add(e);
}
}
//throw new UnsupportedOperationException("This feature isn't implemented yet");
//throw new UnsupportedOperationException("This feature isn't implemented yet");
}
}
private Vector(List<Double> elements) {
private Vector(List<Double> elements) {
this.lst=new ArrayList<Double>();
this.lstVector=new ArrayList<Double>();
for(double e:elements)
for(double e:elements)
{
{
lst.add(e);
lstVector.add(e);
}
}
//throw new UnsupportedOperationException("This feature isn't implemented yet");
//throw new UnsupportedOperationException("This feature isn't implemented yet");
}
}
@@ -45,9 +46,9 @@ final public class Vector {
@@ -45,9 +46,9 @@ 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.lst)
for(double e:that.lstVector)
{
{
this.lst.add(e);
this.lstVector.add(e);
}
}
return this;
return this;
}
}
@@ -100,7 +101,7 @@ final public class Vector {
@@ -100,7 +101,7 @@ final public class Vector {
Vector v = new Vector();
Vector v = new Vector();
for(double e:elements)
for(double e:elements)
{
{
v.lst.add(e);
v.lstVector.add(e);
}
}
return v;
return v;
//throw new UnsupportedOperationException("This feature isn't implemented yet");
//throw new UnsupportedOperationException("This feature isn't implemented yet");
@@ -145,7 +146,13 @@ final public class Vector {
@@ -145,7 +146,13 @@ final public class Vector {
@Override
@Override
public String toString() {
public String toString() {
throw new UnsupportedOperationException("This feature isn't implemented yet");
List<String> strings = new ArrayList<String>();
 
for (Double d : this.lstVector) {
 
// Apply formatting to the string if necessary
 
strings.add(d.toString());
 
}
 
return "Vector"+String.valueOf(strings);
 
//throw new UnsupportedOperationException("This feature isn't implemented yet");
}
}
@Override
@Override
Loading