-5

I need to make the method calculaDesconto based on what the method defineCategoria in the cliente class returned to me and i just can't find a way to make it work.

http://pastebin.com/4ta8dQUM

Rutzen
  • 1
  • 2

1 Answers1

0

I don't understand the question, but if you're simply asking why you can't use the 'pontos' variable in the Compra.java class, the answer should be straight forward: use the getter method you created in the Cliente.java class.

How to use the getter method? In the Compra.java class you passed a reference of the Cliente.java class in the Compra.java class's constructor.

public Compra(int numero, double valorInicial, Cliente clientes) {

And you stored the reference to the data member:

private Cliente clientes;

So now, in the Compra.java class (and to answer the question I assumed earlier), access the getter in the calculaDesconto() and use the variable by:

public double calculaDesconto() {
    if (valorInicial < 50.00)
        valorFinal = valorInicial;
    else if (clientes.getPontos() == 'A')
        valorFinal = valorInicial * 0.05;
    else if (clientes.getPontos() == 'B')
        valorFinal = valorInicial * 0.035;
    else {
        valorFinal = valorInicial * 0.01;
    }
}

Note, the use of the clientes.getPontos() getter method has replaced the former, pontos.

Nick Bell
  • 506
  • 3
  • 15
  • thank you so much for clarifying that i'm a beginner and it's quite the challange up until now. – Rutzen Sep 23 '16 at 22:35