accessor
public class CarPart {
private String name;
private int stockQuantity;
public CarPart(String nme, int qty) {
name=nme; stockQuantity=qty;
}
public void updateStockQuantity(int n) {
stockQuantity += n;
}
public void setStockQuantity(int n) {
stockQuantity = n;
}
public int getStockQuantity() {
return stockQuantity;
}
public static void main(String[] args) {
CarPart cp0 = new CarPart("axle",72);
CarPart cp1 = new CarPart("bonnet",25);
CarPart cp2 = new CarPart("shaft",31);
cp1.updateStockQuantity(-1);
}
}