⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 invoice.java

📁 商品库存管理系统JAVA程序,不需要数据库.很小源程序可使用Jdk1.3以上的任何版本编译和运行
💻 JAVA
字号:
package chapter1;

import javax.swing.JOptionPane;

public class Invoice extends SortedList {
	//定义与提货清单关联的存货清单
	private Inventory inventory;

	//提货清单构造函数
	public Invoice(Inventory _inventory) {
		//调用父类SortedList的构造函数
		super(new ItemComparer());
		inventory = _inventory;
	}

	//在提货清单中增加提货条目,同时在存货清单中对应的存货条目上减少用户输入的货物数量
	public void addItem(String _id, int _number) {
		InventoryItem item = inventory.getPart(_id);
		if ((item != null) && (item.units >= _number) && (_number >= 0)
				&& !isFull()) {
			item.remove(_number);
			add(new InvoiceItem(item, _number));
		} else
			JOptionPane.showMessageDialog(null, "列表满、项没有找到或者货物已经定购完!", "警告",
					JOptionPane.ERROR_MESSAGE);
		System.out.println("List full, item not found or invalid units");
	}

	//根据用户输入的id,在提货清单上删除提货条目
	public void delItem(String _id) {
		int index = indexOf(new Item(_id));
		if (index >= 0)
			delete(index);
	}

	//返回提货清单上货物的价格总和
	public double getTotal() {
		double total = 0.0;
		for (int i = 0; i < getSize(); i++)
			total += ((InvoiceItem) get(i)).total;
		return total;
	}

	//以字符串的形式返回提货清单
	public String toString() {
		return "提货清单:" + Util.dollar(getTotal()) + super.toString();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -