分享好友 数智知识首页 数智知识分类 切换频道

Java编写的高效超市进销存管理系统

以下是一个使用Java编写的高效超市进销存管理系统的基本框架。该系统包括商品管理、库存管理、销售管理和报表生成等功能。...
2025-01-21 23:33100

以下是一个使用Java编写的高效超市进销存管理系统的基本框架。该系统包括商品管理、库存管理、销售管理和报表生成等功能。

```java

import java.util.*;

class Product {

String name;

double price;

int quantity;

public Product(String name, double price, int quantity) {

this.name = name;

this.price = price;

this.quantity = quantity;

}

}

class Inventory {

List products;

public Inventory() {

products = new ArrayList<>();

}

public void addProduct(Product product) {

products.add(product);

}

public void removeProduct(Product product) {

products.remove(product);

}

public List getProducts() {

return products;

}

}

class Sales {

Map sales;

public Sales() {

sales = new HashMap<>();

}

public void addSales(String productName, int quantity) {

sales.put(productName, sales.getOrDefault(productName, 0) + quantity);

}

public void removeSales(String productName, int quantity) {

    sales.put(productName, sales.getOrDefault(productName, 0)
  • quantity);

}

public Map getSales() {

return sales;

}

}

Java编写的高效超市进销存管理系统

class Report {

Map totalSales;

Map totalQuantity;

public Report() {

totalSales = new HashMap<>();

totalQuantity = new HashMap<>();

}

public void addTotalSales(String productName, int quantity) {

totalSales.put(productName, totalSales.getOrDefault(productName, 0) + quantity);

}

public void addTotalQuantity(String productName, int quantity) {

totalQuantity.put(productName, totalQuantity.getOrDefault(productName, 0) + quantity);

}

public Map getTotalSales() {

return totalSales;

}

public Map getTotalQuantity() {

return totalQuantity;

}

}

public class SupermarketInventorySystem {

private Inventory inventory;

private Sales sales;

private Report report;

public SupermarketInventorySystem() {

inventory = new Inventory();

sales = new Sales();

report = new Report();

}

public void addProduct(String name, double price, int quantity) {

inventory.addProduct(new Product(name, price, quantity));

sales.addSales("" + name, quantity);

report.addTotalSales("" + name, quantity);

}

public void removeProduct(String name) {

inventory.removeProduct(new Product("" + name, "", 0));

sales.removeSales("" + name, 0);

report.addTotalQuantity("" + name, 0);

}

public void printReport() {

System.out.println("Total Sales: " + report.getTotalSales());

System.out.println("Total Quantity: " + report.getTotalQuantity());

}

}

```

这个系统使用了三个类:`Product`用于表示商品,`Inventory`用于表示库存,`Sales`用于表示销售,`Report`用于表示报表。在主类`SupermarketInventorySystem`中,我们创建了这三个类的对象,并实现了添加商品、删除商品、打印报表等方法。

举报
收藏 0
推荐产品更多
蓝凌MK 蓝凌MK

办公自动化136条点评

4.5星

简道云 简道云

低代码开发平台85条点评

4.5星

帆软FineBI 帆软FineBI

商业智能软件93条点评

4.5星

纷享销客CRM 纷享销客CRM

客户管理系统105条点评

4.5星

推荐知识更多