1
There is the +fazUmaCompra method in the Customer class that calculates the discount and the customer’s points, and at the end of the method, an object of type Purchase should be instantiated, but I cannot instantiate the object purchased.
Attributes and Constructor of class "Purchase":
public class Compra{
private String numero;
private Cliente cliente;
private Vendedor vendedor;
private double precoOriginal;
private double desconto;
private double preco;
public Compra(double pO, double ds, double pF, Cliente client){
cliente = client;
String s = cliente.getNome();
String sub = s.substring(0, 3);
String num = String.valueOf((int)(Math.random()*10000+100));
numero = num + sub;
precoOriginal = pO;
desconto = ds;
preco = pF;
}
Class method "Client":
public Compra fazUmaCompra(double p){
double pf = 0;
double ds = 0;
if (p > 300){
if (pontos > 2000){
pf = p - (p * 0.05);
ds = pf - p;
pontos = 0;
}
else if (pontos > 1000){
pf = p - (p * 0.03);
ds = pf - p;
pontos = pontos - (int) p * 1;
}
else if (pontos > 500){
pf = p - (p * 0.02);
ds = pf - p;
pontos = pontos - (int) p * 1;
}
else
pf = p;
}
pontos = pontos + (int) p * 1;
Compra c = new Compra(p, ds, pf, this.Cliente);
return c;
When compiling, Bluej marks "this.Client" as error. " Cannot find Symbol - variable Client. Thank you
Instead of
this.Cliente
write onlythis
– ramaral
Thank @ramaral , Beginner Idiot Hahah error
– leonardokbruksch
put points = points + (int) p * 1; Purchase c = new Purchase(p, ds, pf, this.Customer); Return c;
– asousajose
@asousajose actually the keys are from if, it is that it is badly identado
– Math