public class Product {
privateString name;
privatedouble price;
privatedouble value;
privateint quantity;
publicString getName() {
returnname;
}
publicvoid setName(String name) {
this.name = name;
}
publicdouble getValue() {
returnvalue;
}
publicvoid setValue(double value) {
this.value= value;
}
publicint getQuantity() {
returnquantity;
}
publicvoid setQuantity(int quantity) {
this.quantity= quantity;
}
publicdouble getPrice() {
returnprice;
}
publicvoid setPrice(double price) {
this.price= price;
}
publicdouble getProfit() {
returnthis.value - this.price;
}
@Override
publicString toString() {
return"Product name: " + name;
}
}
Comments
Leave a comment