-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector.java
More file actions
60 lines (51 loc) · 1.37 KB
/
Copy pathVector.java
File metadata and controls
60 lines (51 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import java.util.ArrayList;
public class Vector implements Operand
{
public Vector(String vectorString )
{
String[] stringValues = vectorString.split(",");
this.components = new Double[stringValues.length];
for(int i = 0 ; i < stringValues.length ; i++)
{
this.components[i]= Double.parseDouble( stringValues[i] );
}
}
public Vector(Double[] values)
{
this.components= new Double[values.length];
for(int i = 0 ; i<values.length ;i++)
{
this.components[i] = values[i];
}
}
private Double[] components;
public Boolean vectorsAreSameSize( Vector otherVector )
{
Boolean returnBool = true;
Integer otherVectorSize = Integer.parseInt( otherVector.getSize() );
if (otherVectorSize != this.components.length)
{
returnBool = false;
}
return returnBool;
}
public double getComponent( int i )
{
return this.components[i];
}
@Override
public String getSize()
{
return Integer.toString( this.components.length );
}
@Override
public void print()
{
String outputString= new String();
for ( int i = 0; i < this.components.length;i++)
{
outputString+= components[i] + " ";
}
System.out.println(outputString);
}
}