Skip to content

Commit 8094473

Browse files
committed
Novos exer
1 parent bbba3b5 commit 8094473

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

ListaL0.1/Exercicio2/Exercicio2.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package Exercicio2;
2+
3+
import java.util.Scanner;
4+
5+
class Autor {
6+
private String nome;
7+
private int id;
8+
9+
public String getNome () {
10+
return this.nome;
11+
}
12+
13+
public int getId () {
14+
return this.id;
15+
}
16+
17+
public String setNome (String nome) {
18+
return this.nome = nome;
19+
}
20+
21+
public int setNome (int id) {
22+
return this.id = id;
23+
}
24+
}
25+
26+
class Exercicio2 {
27+
public static void main(String arg[]) {
28+
29+
Autor b = new Autor();
30+
System.out.println("Nome: %c" + b.getNome());
31+
System.out.println("Nome: %d" + b.getId());
32+
33+
System.out.println("Nome: %c" + b.getNome(a.nome));
34+
System.out.println("Nome: %d" + b.getId(a.id));
35+
}
36+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import java.util.Scanner;
2+
3+
class Pessoa {
4+
int idade;
5+
}
6+
7+
class MetodoParaLerDoTeclado {
8+
public static void main(String args[]) {
9+
Scanner s = new Scanner(System.in);
10+
Pessoa p = new Pessoa();
11+
System.out.println("Digite qual sua idade:");
12+
p.idade = s.nextInt();
13+
System.out.println("Sua idade é : " + p.idade);
14+
s.close();
15+
}
16+
}

ListaL0.2/Exercicio1.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import java.util.Scanner;
2+
class Pessoa {
3+
private String nome;
4+
private int idade;
5+
private float peso;
6+
7+
String getNome() {
8+
return this.nome;
9+
}
10+
void setNome(String nome) {
11+
this.nome = nome;
12+
}
13+
int getIdade() {
14+
return this.idade;
15+
}
16+
void setIdade(int idade) {
17+
this.idade = idade;
18+
}
19+
float getPeso() {
20+
return this.peso;
21+
}
22+
23+
void setPeso(float peso) {
24+
this.peso = peso;
25+
}
26+
// Imprime todas as propriedades da classe
27+
void imprimeDados() {
28+
System.out.println("Este é o nome: %s"+ nome);
29+
System.out.println("Este é o nome: %d"+ idade);
30+
System.out.println("Este é o nome: %f"+ peso);
31+
}
32+
}
33+
34+
class Ecercicio1 {
35+
public static void main (String args[]) {
36+
Pessoa a = new Pessoa();
37+
Scanner teclado = new Scanner(System.in);
38+
39+
System.out.println("Digite o nome: ");
40+
a.setNome(a) = teclado.nextLine();
41+
42+
System.out.println("Digite a idade: ");
43+
a.setIdade(a) = teclado.nextInt();
44+
45+
System.out.println("Digite seu peso: ");
46+
a.setPeso(a) = teclado.nextLine;
47+
48+
a.imprimeDados();
49+
}
50+
}

0 commit comments

Comments
 (0)