hi
I am really having a problem on making a project of inventory system in Java.
The project says:
The inventory control system should have
1. Login in to the system.
2. Adding new items.
3. Modifying data of selective item.
4. Deleting existing items.
5. Check the stock availability.
6. Real time stock management (ie. When purchase happen you have to increase the stock availability and if sales occurs you have to reduce the stock availability.)

I any can help, it will be really a good help.

Thanks

Dani AI

Generated

A practical way to finish this as a 5‑day homework project is to treat it as an MVP: a solid Item model that includes quantity and stock-adjust methods, a small repository layer (in-memory + simple persistence), a minimal UI (console or lightweight Swing) to exercise add/modify/delete and sales/purchases, and a very small login stub. Prioritize correctness (no negative stock, input validation, unique barcodes) and immediate persistence of any stock change so the state is never lost.

Quick review of the posted snippets () and what to fix first:

  • Java is case-sensitive: class names, array types and references must match exactly (for example Item vs item and inventory vs Inventory).
  • Constructor bug: constructors must not have a return type (remove void); otherwise the default no-arg constructor is used.
  • API mismatches: method names called must exist (e.g., countItem vs countItems) and array bounds / null checks must be added before printing elements.
  • Input handling: use nextLine() for multi‑word names and trim/validate input; protect against duplicate barcodes.
  • Data model missing quantity/stock: add an integer quantity and provide atomic methods to increase/decrease it with validation.
  • Use a dynamic collection (ArrayList or Map keyed by barcode) instead of a fixed array for simplicity and safety.
  • For “real‑time” behavior at homework scale, persist immediately after each change (write a line to a CSV/JSON or update an embedded DB). For multi-user production, use a transactional DB.

Small, safe Item example (replace the class in the posted code with something like this):

public class Item {
    private final String barcode;
    private String name;
    private double price;
    private int quantity;

    public Item(String name, String barcode, double price, int quantity) {
        if (price < 0 || quantity < 0) throw new IllegalArgumentException();
        this.name = name;
        this.barcode = barcode;
        this.price = price;
        this.quantity = quantity;
    }

    public synchronized void adjustStock(int delta) {
        if (delta < 0 && quantity + delta < 0) throw new IllegalStateException("Insufficient stock");
        quantity += delta;
    }

    public synchronized int getQuantity() { return quantity; }

    @Override
    public String toString() {
        return String.format("%s (code:%s) price: %.2f qty:%d", name, barcode, price, quantity);
    }
}

Persistence and testing notes: for quick delivery write a small CSV or JSON file after each change (write to a temp file and atomic-rename). If using JDBC, use an embedded DB (H2/SQLite) and commit each stock update. Add unit tests for increase/decrease edge cases (zero, negative, concurrent access if applicable). Mentioning earlier offers: accept help from volunteers like only after sharing a concise spec and the corrected code skeleton above; and as suggested, post the current code early so volunteers can review concrete errors.

Recommended Answers

All 7 Replies

Well you could do this many ways....use html form as front end and connect to some database and perform all the functionalities...or use swings and use a text file as a persistent store...how r u supposed to do this?

I am thanking all who has tried to help me.
If anyone has done this type of inventory system and has a copy on the computer, i will be highly appreciated if you can send me a copy.

I am really stucked as I got 5 days to submit.

!!!!!!! THANKS !!!!!!!!!!

Well, that's plenty of time - provided you have actually learned anything in your class so far.

Get to work or fail the project. It's all up to you. No one is going to just give you a copy of this.

Written such a system, took about half a year for a 5 man team :)
Of course that was slightly more powerful, robust, and flexible than your average homework assignment :)

Hey dude....
i will try to develop the application for you....give me a clearcut specifications of what you want me to develop and what java technologies(JEE) you want me to use....or is it just enough if i use J2SE core concepts....make sure you give me a full description of the problem....dont give me some form of vague description of the problem....hurry up....mail the problem to <<Email Snipped>>
all the best...

commented: What do you think he will learn for that -2
commented: Read post #2 -1
commented: Do you even know the purpose of this forum? -1

hey guys.. i could really use some help.. im writing this in java.. i hv absolutely no clue what i should be doing.. cuz out lecturer is rubish..
but..
i did some reading and i tried something out i dunno if you guys could help...
i made two classes Inventory and Item

i will past the code i have written...

what i really want to know how 2 do tho is number 6. which is

" real time management" ( no clue what this is or where to start)
this is as far as reading ( as a complete newbie) got me..
please help me out guys...
most important is number 6 the real time management ( which i have not written cuz i dpont know how)\
thank u
here is the code

Inventory src code :

public class inventory {
	private static Item[] inventory;
	private static Scanner sc;
	private static int noOfItems;
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		noOfItems=0;		
		sc=new Scanner(System.in);
		// TODO Auto-generated method stub
		inventory=new item[10];
		run();		
	}
	
	public static int displayMenu()
	{
		System.out.println("1.Add Item");
		System.out.println("2.Find Item");
		System.out.println("3.Delete Item");
		System.out.println("4.Count Item");
		System.out.println("5.Exit");
		System.out.println("Please enter your choice:");
		int i=sc.nextInt();
		return i;	
	}
	
	public static void run()
	{
		while(true)
		{
			int i=displayMenu();
			switch(i)
			{
			case 1:addItem();
					break;
			case 2:findItem();
					break;
			case 4:countItem();
					break;
			case 5:return;
			default:System.out.println("Invalid choice");
			}
		}
	}
	
	public static void addItem()
	{
		System.out.print("Enter Item namme:");
		String item_name=sc.next();
		System.out.print("Enter barcode:");
		String barcode=sc.next();
		System.out.print("Enter price:");
		double price=sc.nextDouble();
		Item b=new Item(item_name,barcode,price);
		if(noOfItems==inventory.length)
			System.out.println("Array is full");
		else
		{
			inventory[noOfItems++]=b;
			System.out.println("Item added successfully");
		}
	}	
	
	public static void findItem()
	{
		System.out.print("Enter item name:");
		String item_name=sc.next();
		for(int i=0; i<noOfItems; i++)
		{
			if(item_name.equalsIgnoreCase(inventory[i].getItem_name()))
			{
				System.out.println("Item found:");
				System.out.print(Inventory[i]);
				return;
			}							
		}		
		
	}
	
	public static void countItems()
	{
		System.out.println("Num of items:"+noOfItems);
		for(int i=0; i< noOfItems; i++)
			System.out.println(inventory[i]);
	}

}

ITEM src codehere

public class item {

	private String item_name;
	private String barcode;
	private double price;
	
	//To initialise the state of the object
	public void Item(String item_name,String barcode,double price)
	{
		this.item_name=item_name;
		this.barcode=barcode;
		this.price=price;
	}
	
	//Reader methods i.e behavior methods
	public String getItem_name()
	{
		return item_name;
	}
	
	public String getBarcode()
	{
		return barcode;
	}
	
	public double getPrice()
	{
		return price;
	}
	
	//Writer methods or setter methods
	public void setTitle(String item_name)
	{
		this.item_name=item_name;
	}
	
	public void setPrice(double price)
	{
		if(price < 0)
					System.out.println("Price cannot be negative");
		else
			this.price=price;
	}
	
	public void setBarcode(String barcode)
	{
		this.barcode=barcode;
	}
	public String toString()
	{
		return "Item name:"+item_name+",Barcode:"+barcode+",Price:"+price;
	}

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.