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

📄 shangpinguanli.java

📁 商品管理
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
				break;
		}
		return i;
	}

	static int reverseHuogui(String s) {
		int i = 0;
		for (i = 0; i < huogui.length; i++) {
			if (huogui[i].equals(s))
				break;
		}
		return i;
	}

	static int reverseStr(String str[], String s) {

		int i = 0;
		for (i = 0; i < str.length; i++) {
			if (str[i].equals(s))
				break;
		}

		return i;
	}

	// 不推荐使用
	void chgNode(Gnode n, int i) {
		n.number = i;
		ID--;
	}

	void add(Gnode o) {
		Count++;
		ID++;
		if (head == null)
			head = o;
		else {
			Gnode temp = head;
			while (temp.next != null)
				temp = temp.next;
			temp.next = o;
		}
	}

	int dec(int n) {
		if (head == null)
			return 0;
		else if (head.number == n) {
			if (head.stored > 0) {
				head.stored--;
				return head.stored;
			}

		} else {

			Gnode temp = head;
			while (temp != null && temp.number != n) {
				temp = temp.next;
			}
			if (temp.stored > 0) {
				temp.stored--;
				return temp.stored;
			}
		}

		return 0;

	}

	int decMore(int n,int num) {
		if (head == null)
			return 0;
		else if (head.number == n) {
			if (head.stored > 0) {
				head.stored--;
				return head.stored;
			}

		} else {

			Gnode temp = head;
			while (temp != null && temp.number != n) {
				temp = temp.next;
			}
			if (temp.stored > 0 && (temp.stored-num)>=0) {
				temp.stored-=num;
				return temp.stored;
			}else
				return 0;
		}

		return 0;

	}
	
	
	boolean remove(int n) {
		if (head == null)
			return false;
		else if (head.number == n) {
			head = head.next;
			Count--;
			return true;
		} else {

			Gnode temp = head;

			while (temp.next != null && temp.next.number != n) {

				temp = temp.next;

			}
			if (!(temp.next == null)) {
				Gnode temp1 = temp.next;
				temp.next = temp1.next;
				temp1 = null;
				Count--;
				return true;
			} else {

			}
		}
		return false;
	}
	
	
	

	Gnode peek(int n) {

		if (head == null)
			return null;
		else if (head.number == n) {

			return head;

		} else {

			Gnode temp = head;
			while (temp != null && temp.number != n) {
				temp = temp.next;
			}
			return temp;
		}

	}

	String[][] statGoods(int orderby) {
		String Result[][];
		double sumprice[];
		int sumstored[];
		int sumclass[];
		Gnode temp;
		int gCount = 0;
		String str[] = {};
		switch (orderby) {
		case 1:
			gCount = huogui.length;
			str = huogui;
			break;
		case 2:
			gCount = Goods.length;
			str = Goods;
			break;
		case 3:
			String From = "";
			temp = head;
			while (temp != null) {
				if (From.indexOf(temp.from) < 0)
					From += (temp.from + "#");
				temp = temp.next;
			}
			From = From.substring(0, From.length() - 1);
			str = From.split("#");
			gCount = str.length;

			break;
		default:

		}

		Result = new String[gCount + 1][4];
		sumprice = new double[gCount + 1];
		sumstored = new int[gCount + 1];
		sumclass = new int[gCount + 1];

		temp = head;
		while (temp != null) {
			int tem = (orderby < 2) ? reverseStr(str, temp.shelf)
					: ((orderby == 2) ? reverseStr(str, temp.goods)
							: reverseStr(str, temp.from));
			sumstored[tem] += temp.stored;
			sumstored[gCount] += temp.stored;

			sumprice[tem] += temp.price * temp.stored;
			sumprice[gCount] += temp.price * temp.stored;

			sumclass[tem]++;
			sumclass[gCount]++;

			temp = temp.next;
		}

		for (int i = 0; i < gCount; i++) {
			Result[i][0] = sumstored[i] + "";
			Result[i][1] = sumprice[i] + "";
			Result[i][2] = sumclass[i] + "";
			Result[i][3] = str[i] + "";
		}

		Result[gCount][0] = sumstored[gCount] + "";
		Result[gCount][1] = sumprice[gCount] + "";
		Result[gCount][2] = sumclass[gCount] + "";
		Result[gCount][3] = "总计";

		return Result;

	}

	void removeAll() {
		head = null;
		Count = 0;
	}

}
//商品基节点类
class Gnode {
	int number = GList.ID;

	String goods = "商品";

	String name = "";

	static String property[] = { "名字", "尺寸", "单价", "产地", "库存", "所属货柜" };

	String shelfproperty[] = {};

	double size = 0;

	double price = 0;

	String from = "";

	int stored = 0;

	String shelf = "";

	Gnode next;

	Gnode() {

	}

	Gnode(String nam, double s, double p, String f, int st, String sh) {
		name = nam;
		size = s;
		price = p;
		from = f;
		stored = st;
		shelf = sh;
	}

	void printGoods() {
		System.out.println("尺寸: " + size + " 价格: " + price + " 产地: " + from
				+ " 库存: " + stored + " 货柜: " + shelf);
	}

	String[] getEntity() {
		String s[] = new String[property.length + 1];
		s[0] = String.valueOf(number);
		s[1] = name;
		s[2] = String.valueOf(size);
		s[3] = String.valueOf(price);
		s[4] = from;
		s[5] = String.valueOf(stored);
		s[6] = String.valueOf(shelf);

		return s;
	}
}
//衣物节点类
class GClose extends Gnode {
	static String shelfproperty[] = { "布料", "样式" };

	String close = "";

	String style = null;

	GClose() {
		super();
	}

	GClose(String nam, double s, double p, String f, int st, String sh,
			String good, String cl) {
		super(nam, s, p, f, st, sh);
		goods = good;

		close = cl;
	}

	GClose(String nam, double s, double p, String f, int st, String sh,
			String good, String cl, String sty) {
		super(nam, s, p, f, st, sh);
		goods = good;
		close = cl;
		style = sty;
	}

	void printGoods() {
		System.out.println("商品属性:" + goods);
		System.out.println("商品名字:" + name);
		System.out.println(shelfproperty[0] + ": " + close);
		if (!(style == null))
			System.out.println(shelfproperty[1] + ": " + style);
		super.printGoods();
	}

}
//电器节点类
class GElectronic extends Gnode {
	static String shelfproperty[] = { "颜色", "样式", "重量", "制冷类型" };

	String color = "";

	String style = "";

	double weight = 0;

	String coldmakestyle = null;

	GElectronic() {
		super();
	}

	GElectronic(String nam, double s, double p, String f, int st, String sh,
			String good, String col, String sty, double wei) {
		super(nam, s, p, f, st, sh);
		goods = good;
		color = col;
		style = sty;
		weight = wei;
	}

	GElectronic(String nam, double s, double p, String f, int st, String sh,
			String good, String col, String sty, double wei, String cms) {
		super(nam, s, p, f, st, sh);
		goods = good;
		color = col;
		style = sty;
		weight = wei;
		coldmakestyle = cms;

	}

	void printGoods() {
		System.out.println("商品名字:" + goods);
		System.out.println(shelfproperty[0] + ": " + color);
		System.out.println(shelfproperty[1] + ": " + style);
		System.out.println(shelfproperty[2] + ": " + weight);
		if (!(coldmakestyle == null))
			System.out.println(shelfproperty[3] + ": " + coldmakestyle);
		super.printGoods();
	}

}

//家居节点类
class GWood extends Gnode {
	static String shelfproperty[] = { "木料", "颜色", "皮料" };

	String color = "";

	String timber = "";

	String piliao = null;

	GWood() {
		super();
	}

	GWood(String nam, double s, double p, String f, int st, String sh,
			String good, String col, String sty) {
		super(nam, s, p, f, st, sh);
		goods = good;
		color = col;
		timber = sty;

	}

	GWood(String nam, double s, double p, String f, int st, String sh,
			String good, String col, String sty, String pl) {
		super(nam, s, p, f, st, sh);
		goods = good;
		color = col;
		timber = sty;
		piliao = pl;

	}

	void printGoods() {
		System.out.println("商品名字:" + goods);
		System.out.println(shelfproperty[0] + ": " + color);
		System.out.println(shelfproperty[1] + ": " + timber);

		if (!(piliao == null))
			System.out.println(shelfproperty[3] + ": " + piliao);
		super.printGoods();
	}

}

⌨️ 快捷键说明

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