package demo_ass;
import utils.AttrRef;
import utils.DOpt;
import utils.DomainConstraint;
import utils.NotPossibleException;
import utils.OptType;
import utils.NotPossibleException;
public class HighEarner extends Customer{
@DomainConstraint(type = "Float", mutable =true , optional = false, min = 10000000)
private float income;
public HighEarner(@AttrRef("name")int i,@AttrRef("name") String n,@AttrRef("address") String a,@AttrRef("phoneNumber") String ph,@AttrRef("income")float in) {
super(i, n, a, ph);
if (validate(in)) {
income = in;
} else
System.err.println("invalid income");
}
private boolean validate(float in) {
return validateIncome(in);
}
@DOpt(type=OptType.Observer) @AttrRef("income")
public Float getIncome() {
return income;
}
@DOpt(type=OptType.Mutator) @AttrRef("income")
public void setIncome(Float income) {
if (validateIncome(income)) {
this.income = income;
}else {
System.err.println("Customer.setIncome: invalid income: " + income);
}
}
private boolean validateIncome(float in) {
if(in<10000000) {
return false;
}
else {return true;
}
}
public boolean repOk() {
return super.repOk()&& validateIncome(this.income);
}
public String toString() {
return super.toString()+ " "+ this.income;
}
public int compareTo(Customer kh)
throws NullPointerException, ClassCastException {
// compare two bus objects by name
return super.compareTo(kh);
}
}
ai xem jup minh code nay lỗi j mà minh in ra nỗi dung của oj chỗ income float luôn có 1.23434435E10