Skip to content

Commit 8dd3c4e

Browse files
committed
- Commit do Exercício 2 (enunciado na pasta 'exercise') do Capítulo 2
0 parents  commit 8dd3c4e

File tree

5 files changed

+44
-0
lines changed

5 files changed

+44
-0
lines changed

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

EX-CAP-02-02/src/Data.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
public class Data {
3+
private int dia;
4+
private int mes;
5+
private int ano;
6+
7+
public Data(int d, int m, int a){
8+
dia = d;
9+
mes = m;
10+
ano = a;
11+
}
12+
13+
public int get (int e){
14+
switch(e){
15+
case 1:
16+
return dia;
17+
case 2:
18+
return mes;
19+
case 3:
20+
return ano;
21+
default:
22+
return -1;
23+
}
24+
}
25+
26+
public String getString(){
27+
return Integer.toString(dia) + "/" + Integer.toString(mes) + "/" + Integer.toString(ano);
28+
}
29+
}

EX-CAP-02-02/src/EX0202.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
public class EX0202 {
3+
4+
public static void main(String[] args) {
5+
Data d = new Data(11, 8, 2011);
6+
String meses[]={"JAN","FEV","MAR","ABR","MAI","JUN","JUL","AGO","SET","OUT","NOV","DEZ"};
7+
8+
System.out.println("Data Editada: " + d.getString());
9+
System.out.println(d.get(1) + " de " + meses[d.get(2) - 1] + " de " + d.get(3));
10+
}
11+
}

0 commit comments

Comments
 (0)