Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class VectorRepo {
- private List<IVector> vectorList;
- public void addVector(IVector v) {
- this.vectorList.add(v);
- }
- public void removeVector(IVector v) {
- this.vectorList.remove(v);
- }
- public IVector getVector(double[] v) {
- double length = v.length;
- for(IVector vector : vectorList) {
- if(vector instanceof Vector3D && length == 3) {
- if(vector.getVx() == v[0] && vector.getVy() == v[1] && ((Vector3D)vector).getVz() == v[2]) {
- return vector;
- }
- } else if (vector instanceof Vector && length == 2) {
- if(vector.getVx() == v[0] && vector.getVy() == v[1]) {
- return vector;
- }
- } else continue;
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement