Skip to content

Commit 203bfc3

Browse files
committed
- Commit do Exercício 1 (enunciado na pasta 'exercise') do Capítulo 3
1 parent 8e22cc0 commit 203bfc3

File tree

5 files changed

+49
-0
lines changed

5 files changed

+49
-0
lines changed

EX-CAP-03-01/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/bin/
2+
/.classpath
3+
/.project

EX-CAP-03-01/.settings/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/org.eclipse.jdt.core.prefs
94.8 KB
Binary file not shown.

EX-CAP-03-01/src/EX0301.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
public class EX0301 {
3+
4+
public static void main(String[] args) {
5+
Vetor vetor1 = new Vetor(3, 4);
6+
Vetor vetor2 = new Vetor(7, 6);
7+
8+
vetor1.soma(vetor2);
9+
vetor1.exibe();
10+
}
11+
}

EX-CAP-03-01/src/Vetor.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
public class Vetor {
3+
// Variáveis
4+
private double x;
5+
private double y;
6+
7+
public Vetor(){
8+
x = 0.0;
9+
y = 0.0;
10+
}
11+
12+
public Vetor(double x) {
13+
this.x = x;
14+
y = 0.0;
15+
}
16+
17+
public Vetor(double x, double y) {
18+
this.x = x;
19+
this.y = y;
20+
}
21+
22+
{
23+
exibe();
24+
}
25+
26+
public void soma(Vetor v2) {
27+
x += v2.x;
28+
y += v2.y;
29+
}
30+
31+
public void exibe() {
32+
System.out.println("x = " + x + "; y = " + y);
33+
}
34+
}

0 commit comments

Comments
 (0)