java/php/node.js/python超市进销存管理系统【2024年毕设】
本示例提供了一个超市进销存管理系统的简化版本,主要包括产品管理和销售管理的核心功能。具体实现语言使用Java,PHP,Node.js和Python中的一种。
以下是使用Java实现的简单进销存管理系统示例:
// 产品类(Product)
public class Product {
private String name;
private double price;
private int quantity;
// 构造函数
public Product(String name, double price, int quantity) {
this.name = name;
this.price = price;
this.quantity = quantity;
}
// 获取产品信息
public String getInfo() {
return "Name: " + name + ", Price: " + price + ", Quantity: " + quantity;
}
// 销售产品
public void sellProduct(int quantitySold) {
this.quantity -= quantitySold;
}
// 其他的getter和setter方法
}
// 销售类(Sale)
public class Sale {
private Product productSold;
private int quantitySold;
private double totalSale;
// 构造函数
public Sale(Product productSold, int quantitySold) {
this.productSold = productSold;
this.quantitySold = quantitySold;
this.totalSale = productSold.getPrice() * quantitySold;
productSold.sellProduct(quantitySold);
}
// 获取销售信息
public String getSaleInfo() {
return "Product: " + productSold.getName() + ", Quantity: " + quantitySold + ", Total Sale: " + totalSale;
}
}
// 主类(SupermarketSystem)
public class SupermarketSystem {
private List<Product> products = new ArrayList<>();
// 添加产品
public void addProduct(Product product) {
products.add(product);
}
// 查看产品列表
public void viewProductList() {
for (Product product : products) {
System.out.println(product.getInfo());
}
}
// 进行销售
public Sale makeSale(String productName, int quantity) {
for (Product product : products) {
if (product.getName().equals(productName)) {
return new Sale(product, quantity);
}
}
return null;
}
public static void main(String[] args) {
SupermarketSystem supermarket = new SupermarketSystem();
supermarket.addProduct(new Product("Apple", 1.0, 100));
supermarket.addProduct(new Product("Banana", 0.50, 150));
supermarket.viewProductList();
Sale sale = supermarket.makeSale("Apple", 10);
if (sale != null) {
System.out.println(sale.getSaleInfo(
评论已关闭