java进销存管理系统源码【代码示例】

phpmysqlchengxu

温馨提示:这篇文章已超过239天没有更新,请注意相关的内容是否还可用!

java进销存管理系统源码【代码示例】

进销存管理系统是一种用于管理企业库存、销售和采购等业务流程的软件系统。它能够帮助企业实现库存的精确控制、销售订单的管理、采购订单的跟踪以及财务数据的统计分析等功能。下面是一个简单的Java进销存管理系统的源码示例:

import java.util.ArrayList;

import java.util.List;

public class InventoryManagementSystem {

private List<Product> products;

public InventoryManagementSystem() {

products = new ArrayList<>();

}

public void addProduct(Product product) {

products.add(product);

}

public void removeProduct(Product product) {

products.remove(product);

}

public void updateProductQuantity(Product product, int quantity) {

product.setQuantity(quantity);

}

public void sellProduct(Product product, int quantity) {

if (product.getQuantity() >= quantity) {

product.setQuantity(product.getQuantity() - quantity);

System.out.println("Product " + product.getName() + " sold successfully.");

} else {

System.out.println("Insufficient quantity for product " + product.getName() + ".");

}

}

public void purchaseProduct(Product product, int quantity) {

product.setQuantity(product.getQuantity() + quantity);

System.out.println("Product " + product.getName() + " purchased successfully.");

}

public void printInventory() {

System.out.println("Inventory:");

for (Product product : products) {

System.out.println(product.getName() + " - Quantity: " + product.getQuantity());

}

}

}

public class Product {

private String name;

private int quantity;

public Product(String name, int quantity) {

this.name = name;

this.quantity = quantity;

}

public String getName() {

return name;

}

public int getQuantity() {

return quantity;

}

public void setQuantity(int quantity) {

this.quantity = quantity;

}

}

public class Main {

public static void main(String[] args) {

InventoryManagementSystem inventorySystem = new InventoryManagementSystem();

Product product1 = new Product("Product 1", 10);

Product product2 = new Product("Product 2", 5);

inventorySystem.addProduct(product1);

inventorySystem.addProduct(product2);

inventorySystem.printInventory();

inventorySystem.sellProduct(product1, 3);

inventorySystem.purchaseProduct(product2, 2);

inventorySystem.printInventory();

}

}

以上是一个简单的Java进销存管理系统的源码示例。它包括了一个InventoryManagementSystem类用于管理库存、销售和采购等操作,一个Product类用于表示产品及其数量,以及一个Main类用于演示系统的使用。系统通过addProduct方法添加产品,通过sellProduct方法销售产品,通过purchaseProduct方法采购产品,并通过printInventory方法打印当前库存情况。

文章版权声明:除非注明,否则均为莫宇前端原创文章,转载或复制请以超链接形式并注明出处。

取消
微信二维码
微信二维码
支付宝二维码