Skip to content

Commit dbdd166

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

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

EX-CAP-03-02/.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-02/.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
90.8 KB
Binary file not shown.

EX-CAP-03-02/src/EX0302.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
public class EX0302 {
3+
4+
public static void main(String[] args) {
5+
Xpto x1 = new Xpto();
6+
System.out.println("contInst = " + Xpto.getQtdInst());
7+
8+
Xpto x2 = new Xpto();
9+
System.out.println("contInst = " + Xpto.getQtdInst());
10+
11+
Xpto x3 = new Xpto();
12+
System.out.println("contInst = " + Xpto.getQtdInst());
13+
}
14+
}

EX-CAP-03-02/src/Xpto.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
public class Xpto {
3+
private static int contInst;
4+
5+
public Xpto(){
6+
contInst++;
7+
}
8+
9+
public static int getQtdInst(){
10+
return contInst;
11+
}
12+
}

0 commit comments

Comments
 (0)