Hey, guys. i desperately need some help designing a university project. the project is called Grocery shop. it has a product class which will hold all the products description and set thresholds finally it will need a stock management class which will allow the user to add, remove and edit product it also needs to the store details of products sold on daily basis. I have so far design the product class and set all the thresholds however my knowledge of java is very limited so i don't know how to design the stock management class so i wonder if u guys could kindly help me please. Cheers

I beginner in JAVA programming . I have very difficult assignment .do you knew JAVA to guide and help me to do that?
with best regards

Please Don't Hijack other users Posts - Create your own

It is not going to be that difficult. You just need to store stock entries in database and manage them , have a base class named product and derive all specific products in stock from the class product.

guys, this is what i've done so far however i'm not sure i'm going in the right direction.

public class Product {
	String name;
	double weight;
    int refNumber;
    int qty;
    double price;
    public Product(){
    	name = "";
    	weight = 2.3;
    	refNumber = 001;
    	qty = 20;
    	price = 17.56;
    public Product(String nameIn, int refNumberIn, double weightIn, int qtyIn, double priceIn)
    	 name = nameIn;
    	 qty = qtyIn;
    	 weight = weightIn;
    	 refNumber = refNumberIn;
    	 price = priceIn;
    public String getName()
    	return name;
    public double getWeight()
    	return weight;
    public int getRefNumber()
    	return refNumber;
    public int getQty()
    	return qty;
    public double getPrice()
    		System.out.println("Invalid price!!");
    	return price;
    public String toString()
        return "NAME: " + getName() + "\nREFNUMBER: " + getRefNumber() + "\nWeight: " + getWeight() +
                "\nQTY: " + getQty() + "\nPRICE: " + getPrice();

    The stock management class is to provide the User(Shop owner) with a mechanism 
    which enables he/she to add, remove, edit, alter, and view all the product in 
    the database.
import java.util.ArrayList;

public class StockManagement {
  ArrayList <Product> Products;
 public StockManagement(){
 	 Products = new ArrayList<Product>();
   method to add a new product to the stock management.
   The new product will be added to the ArrayList
 public void addProduct(String nameIn, int refNumberIn, double weightIn, int qtyIn, double priceIn )
 	    //Check that the supplied price is sensible
 	        Product product = new Product(nameIn, refNumberIn, weightIn, qtyIn, priceIn);	
 	        Products.add (product);

  method to display the list of products in the ArrayList
 public String toString()
        // Initialise the string representation of all products to the blank
        // string ("")
        String allProducts = "";

        // Loop through all the products...
        for (int count=0; count<Products.size(); count++)
			// Get hold of the current product
			Product curProduct = Products.get(count);

            // Add the string representation of the current product to the
            // string representation of all product
            allProducts = allProducts + curProduct.toString();
            // Add a new line character
            allProducts = allProducts + "\n";

        // return the string representation of all products
        return allProducts;
   method to remove product from the ArrayList.
   The product will be removed completely from the database.
 public static void main(String args[]){
 	StockManagement management = new StockManagement();
 	//Add product 
 	management.addProduct("Laranga", 111, 1.4, 20, 1.75);
 	management.addProduct("Manga", 111, 1.4, 20, 1.75);
 	management.addProduct("Apple", 111, 1.4, 20, 1.75);
 	management.addProduct("Banana", 111, 1.4, 20, 1.75);
 	management.addProduct("Grapes", 111, 1.4, 20, 1.75);
 	management.addProduct("Peach", 111, 1.4, 20, 1.75);
 	management.addProduct("Avocado", 111, 1.4, 20, 1.75);

I'm not sure if the ArrayList class im using is the most appropriate for storing stock entries in the database.

By the way, the stock entry are to be stored in virtual database as i'm not actually required to physically design a database.

This article has been dead for over six months. Start a new discussion instead.