Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Exemplo em Java
- */
- ...
- public class Exercicio {
- public static void main (String[] args) {
- Aluno aluno = new Aluno("João pedro", 9.3, 9.3, 9.3);
- ...
- }
- }
- class Aluno {
- private String nome;
- private float[] notas = new float[3];
- private float media;
- public Aluno (String nome, float nota1, float nota2, float nota3) {
- this.nome = nome;
- this.notas[0] = nota1;
- this.notas[1] = nota2;
- this.notas[2] = nota3;
- this.media = (nota1 + nota2 + nota3)/3;
- }
- /* o mesmo de C++, procure como fazer getters em classes Java */
- }
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement