Hi, I am working on a code and i need to change the code to make it easier to maintain. I have learned about re use of code so im thinking this is the way i shud be looking at the code but I cant seem to find anything to change.
the code is:
public class Product { /* Instance variables */ public int stockLevel; // The number of items of this product in stock which is updated // by the deliver() and acquire() methods. Objects of other // classes will need to find out its value. public String description; // The name of the product which will be set to a meaningful // string by the constructor, and then never changed. // Objects of other classes will need to find out its value. /** Constructor for objects of class Product public Product(String aDescription) { super(); this.stockLevel = 0; this.description = aDescription; } /* Instance methods */ /** * Reduce the stock level by the value of the argument. * Method presumes availability has already been checked. */ public void deliver(int anAmount) { this.stockLevel = this.stockLevel - anAmount; } /** * Increase the stock level by the value of the argument */ public void acquire(int anAmount) { this.stockLevel = this.stockLevel + anAmount; } /** * Returns a string giving details of the product */ public String productDetails() { return "Product " + this.description + ": " + this.stockLevel + " in stock."; } }what I have come up with so far is I will declare
if someone could help that wud be great.
Thanks