Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Atividade realizada


public class Funcionario {

    private String nome;
    private String cpf;
    private double salario;

    public double getBonificacao() {
        return this.salario * 0.1;
    }

    public String getNome() {
        return nome;
    }
    public void setNome(String nome) {
        this.nome = nome;
    }
    public String getCpf() {
        return cpf;
    }
    public void setCpf(String cpf) {
        this.cpf = cpf;
    }


    public double getsalario() {
        return salario;
    }

    public void setSalario(Double salario) {
        this.salario = salario;
    }









}
public class Gerente extends Funcionario{

private int senha;

public int getSenha() {
    return senha;
}

public void setSenha(int senha) {
    this.senha = senha;
}

public boolean autentica(int senha) {
    if (this.senha == senha) {
        return true;
    } else {
        return false;
    }
}

}

public class TesteFuncionario {

public static void main(String[] args) {

    Funcionario nico = new Funcionario();

    nico.setNome("Nico Steppat");
    nico.setCpf("223355646-9");
    nico.setSalario(2590.80);

    System.out.println(nico.getNome());
    System.out.println(nico.getBonificacao());




}

}

public class TesteGerente {

public static void main(String[] args) {

    Gerente gerente = new Gerente();
    gerente.setCpf("021001444-75");
    gerente.setSalario(3000.00);
    gerente.setSenha(2222);

    System.out.println(gerente.getCpf());
    System.out.println(gerente.getsalario());
    System.out.println(gerente.getSenha());

      gerente.setSenha(2222);
        boolean autenticou = gerente.autentica(2222);

        System.out.println(autenticou);



}

}

1 resposta
solução!

Muito bom Adão, só um ponto de atenção com a formatação do código, por exemplo:

public class TesteGerente {

    public static void main(String[] args) {

        Gerente gerente = new Gerente();
        gerente.setCpf("021001444-75");
        gerente.setSalario(3000.00);
        gerente.setSenha(2222);

        System.out.println(gerente.getCpf());
        System.out.println(gerente.getsalario());
        System.out.println(gerente.getSenha());

          gerente.setSenha(2222);
            boolean autenticou = gerente.autentica(2222);

            System.out.println(autenticou);



    }

}

Poderia ficar:

public class TesteGerente {

    public static void main(String[] args) {

        Gerente gerente = new Gerente();
        gerente.setCpf("021001444-75");
        gerente.setSalario(3000.00);
        gerente.setSenha(2222);

        System.out.println(gerente.getCpf());
        System.out.println(gerente.getsalario());
        System.out.println(gerente.getSenha());

        gerente.setSenha(2222);
        boolean autenticou = gerente.autentica(2222);

        System.out.println(autenticou);
    }
}

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software