How to create method for withdrawal from store and deliverance to store
I am studying java by myself and I want to get help on exercise which i am
doing myself. The class is called Product which used for representing a
product that a small company sells. It should be possible to store the
following information about each product. The class should have the
following methods: • A constructor • A method that returns the units of
items in store • A method for deliverance to the store (increases the
units of this product) • A method for withdrawal from the store (decreases
the units of this product) Please note that if one of the methods changes
the stored items below the order point a message should be printed. It
should also be impossible to have a negative amount of items.
I HAVE PROBLEM WITH METHODS. PLEASE TAKE A LOOK MY CODE AND GIVE ME SOME
HINTS. I WILL APPRECIATE ALL RESPONDS. THANK YOU.
Here is my program:
public class Product {
private int productNumber;
private String productName;
private float price;
private int orderPoint;
private int unitsInStore;
private String proDescription;
public Product(int num, String name, float price, int order, int units,
String description){
this.productNumber = num;
this.productName = name;
this.price = price;
this.orderPoint = order;
this.unitsInStore = units;
this.proDescription = description;
}
public int getProductNumber() {
return productNumber;
}
public void setProductNumber(int productNumber) {
this.productNumber = productNumber;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
this.price = price;
}
public int getOrderPoint() {
return orderPoint;
}
public void setOrderPoint(int orderPoint) {
this.orderPoint = orderPoint;
}
// a method returns the units in store
public int getUnitsInStore() {
return unitsInStore;
}
public void setUnitsInStore(int unitsInStore) {
this.unitsInStore = unitsInStore;
}
public String getProDescription() {
return proDescription;
}
public void setProDescription(String proDescription) {
this.proDescription = proDescription;
}
public int deliveranceToStore(int store){
int unitsInStore = deliveranceToStore(unitsInStore) +store;
return unitsInStore ++;
}
}
No comments:
Post a Comment