-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVector.enc
109 lines (91 loc) · 1.42 KB
/
Vector.enc
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import java.util.*;
class Vector
{
int i;
int j;
int k;
public Vector()
{
i=0;
j=0;
k=0;
}
public Vector(int x)
{
i=x;
j=x;
k=x;
}
public Vector(int x,int y,int z)
{
i=x;
j=y;
k=z;
}
void display()
{
System.out.println("("+i+","+j+","+k+")");
}
public Vector add(Vector v1)
{
Vector temp=new Vector();
temp.i=this.i+v1.i;
temp.j=this.j+v1.j;
temp.k=this.k+v1.k;
return temp;
}
public Vector add(Vector v1,Vector v2)
{
Vector temp= new Vector();
temp.i=this.i+v1.i+v2.i;
temp.j=this.j+v1.j+v2.j;
temp.k=this.k+v1.k+v2.k;
return temp;
}
public Vector product(Vector v1)
{
Vector temp=new Vector();
temp.i=this.i*v1.i;
temp.j=this.j*v1.j;
temp.k=this.k*v1.k;
return temp;
}
public Vector product(Vector v1,Vector v2)
{
Vector temp=new Vector();
temp.i=this.i*v1.i*v2.i;
temp.j=this.j*v1.j*v2.j;
temp.k=this.k*v1.k*v2.k;
return temp;
}
public static Vector sum(Vector v1,Vector v2)
{
Vector temp = new Vector();
temp.i=v1.i+v2.i;
temp.j=v1.j+v2.j;
temp.k=v1.k+v2.k;
return temp;
}
public static int mul(Vector v1,Vector v2)
{
int temp = 0;
temp = v1.i*v2.i+v1.j*v2.j+v1.k*v2.k;
return temp;
}
}
class TestsVector
{
public static void main(String args[])
{
Vector v1 = new Vector(12);
Vector v2 = new Vector(15);
Vector v3 = new Vector(1,2,3);
Vector v5 = v1.add(v2);
Vector v6 = v1.add(v3);
v5.display();
v1.display();
v2.display();
v3.display();
v6.display();
}
}