public class book {
private double basePrice = 0;
private double vat = 0;
private double discount = 0;
private double sellPrice;
public book() {
setBasePrice(0);
setVat(0);
setDiscount(0);
}
public book(double basePrice, double discount, double vat) {
setBasePrice(basePrice);
setVat(discount);
setDiscount(vat);
}
public double getBasePrice() {
return basePrice;
}
public void setBasePrice(double basePrice) {
if (basePrice >= 0)
this.basePrice = basePrice;
setSellPrice();
}
public double getVat() {
return vat;
}
public void setVat(double vat) {
if (vat >= 0)
this.vat = vat;
setSellPrice();
}
public double getDiscount() {
return discount;
}
public void setDiscount(double discount) {
if (discount >= 0)
this.discount = discount;
setSellPrice();
}
public double getSellPrice() {
return sellPrice;
}
private void setSellPrice() {
sellPrice = basePrice * ((100 + (vat - discount)) / 100);
}
}
rs_java -2 Newbie Poster
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
rs_java -2 Newbie Poster
rs_java -2 Newbie Poster
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
rs_java -2 Newbie Poster
rs_java -2 Newbie Poster
rs_java -2 Newbie Poster
rs_java -2 Newbie Poster
Ezzaral commented: Stop posting meaningless fragments of text. -2
jasimp 427 Senior Poster Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.