用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - java代码库

商超管理

2017-11-05 作者: 幽草举报

[java]代码库

import java.util.Scanner;
import com.oraclesdp.common.SystemIn;

public class Supermarket {
	public static Scanner scan = new Scanner(System.in);// 鍦ㄦ帶鍒跺彴杈撳叆
	private static int newshangpinIndex = 0;
	public static String[] shouhuoyuanpass = new String[20];// 鍞揣鍛樺瘑鐮�
	public static String[] shouhuoyuanname = new String[20];// 鍞揣鍛樺悕瀛�
	public static String[] shangpinname = new String[20];// 鍟嗗搧鍚嶇О
	public static int[] shangpinnum = new int[20];// 鍟嗗搧鏁伴噺
	public static float[] shangpinprice = new float[20];// 鍟嗗搧浠锋牸
	private static int newshangpinnums;
	private static String newshangpinames;
	private static float newshangpinprice;

	public static void main(String[] args) throws Exception {

		shouhuoyuanname[0] = "yuanrui";
		shouhuoyuanpass[0] = "123";
		shangpinname[0] = "iPhone4";
		shangpinnum[0] = 100;
		shangpinprice[0] = 1000f;

		shangpinname[1] = "iPhone5";
		shangpinnum[1] = 100;
		shangpinprice[1] = 2000f;

		shangpinname[2] = "iPhone6";
		shangpinnum[2] = 100;
		shangpinprice[2] = 3000f;

		shangpinname[3] = "iPhone7";
		shangpinnum[3] = 100;
		shangpinprice[3] = 4000f;

		shangpinname[4] = "iPhone8";
		shangpinnum[4] = 100;
		shangpinprice[4] = 5000f;
		menu();
	}

	// 鐧诲綍鐣岄潰
	private static void menu() {
		System.out.println("\t\t\t娆㈣繋浣跨敤鍟嗚秴璐墿绠$悊绯荤粺\n");
		System.out.println("****************************************************************");
		System.out.println("\t\t\t\t1.鐧诲綍 \n");
		System.out.println("\t\t\t\t2.娉ㄥ唽 \n");
		System.out.println("\t\t\t\t3.閫�鍑篭n");
		System.out.println("****************************************************************");
		System.out.println("璇烽�夋嫨锛岃緭鍏ユ暟瀛�: ");
		int a = scan.nextInt();
		switch (a) {
		case 0:
			System.out.println("閫�鍑猴紒");
		case 1:
			System.out.println(" 璇疯緭鍏ョ敤鎴峰悕锛�");
			String name = scan.next();
			System.out.println("璇疯緭鍏ュ瘑鐮�:");
			String pass = scan.next();
			int flage = 0;
			int ff = 0;
			for (int i = 0; i < shouhuoyuanname.length; i++) {
				if (name.equals(shouhuoyuanname[i])) {
					flage = 1;
					ff = i;
					break;
				}
			}
			if (flage == 1) {
				if (pass.equals(shouhuoyuanpass[ff])) {
					loadmenu1();
				} else {
					System.out.println("瀵嗙爜閿欒锛� ");
					menu();
				}
			} else
				switch (a) {
				case 2:
					System.out.println("璇ョ敤鎴峰悕鏈敞鍐岃鍏堟敞鍐�");
					break;
				case 3:
					System.out.println("璋㈣阿鎮ㄧ殑浣跨敤!");
					break;
				default:
					menu();
					break;
				}
		}
	}

	// 娉ㄥ唽鐢ㄦ埛
	public static void loadmenu0() {
		System.out.println("\t\t\t娆㈣繋浣跨敤鍟嗚秴璐墿绠$悊绯荤粺\n");
		System.out.println("****************************************************************");
		System.out.println("璇疯緭鍏ョ敤鎴峰悕锛�");
		SystemIn.nextLong();
		System.out.println("璇疯緭鍏ュ瘑鐮侊細");
		SystemIn.nextLong();
		System.out.println("娉ㄥ唽鎴愬姛 璇风櫥褰�");
		loadmenu0();

	}

	// 涓昏彍鍗�
	public static void loadmenu1() {
		System.out.println("\t\t\t娆㈣繋浣跨敤鍟嗚秴璐墿绠$悊绯荤粺\n");
		System.out.println("\t\t\t\t鍟嗗搧绠$悊");
		System.out.println("****************************************************************");
		System.out.println("\t\t\t\t1.娣诲姞鍟嗗搧");
		System.out.println("\t\t\t\t2.淇敼鍟嗗搧");
		System.out.println("\t\t\t\t3.鍒犻櫎鍟嗗搧");
		System.out.println("\t\t\t\t4.鏌ョ湅鍟嗗搧");
		System.out.println("\t\t\t\t5.鎼滅储鍟嗗搧");
		System.out.println("\t\t\t\t6.缁撹处绠$悊");
		System.out.println("****************************************************************");
		System.out.println("璇烽�夋嫨锛岃緭鍏ユ暟瀛楁垨鎸�0閫�鍑猴細");
		// Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		/*
		 * switch (a) { case 0: } System.out.println("璋㈣阿鎮ㄧ殑浣跨敤!");
		 */
		switch (a) {
		case 1:
			System.out.println("娣诲姞鍟嗗搧");
			loadmenu2();
			break;
		case 2:
			System.out.println("淇敼鍟嗗搧");
			loadmenu3();
			break;
		case 3:
			System.out.println("鍒犻櫎鍟嗗搧");
			loadmenu4();
			break;
		case 4:
			System.out.println("鏌ョ湅鍟嗗搧");
			loadmenu5();
			break;
		case 5:
			System.out.println("鎼滅储鍟嗗搧");
			loadmenu6();
			break;
		case 6:
			System.out.println("缁撹处绠$悊");
			loadmenu7();
			break;
		default:
			System.out.println("杈撳叆鏈夎璇烽噸鏂拌緭鍏�");
			loadmenu1();
			break;
		}
	}

	// 娣诲姞鍟嗗搧
	public static void loadmenu2() {
		System.out.println("璇疯緭鍏ュ晢鍝佸悕绉帮細");
		SystemIn.nextLong();
		System.out.println("璇疯緭鍏ュ晢鍝佹暟閲忥細");
		int newshangpinNo = SystemIn.nextInt();
		System.out.println("璇疯緭鍏ュ晢鍝佷环鏍硷細");
		SystemIn.nextFloat();
		if (newshangpinNo >= shangpinname.length) {
			String[] newshangpinnames = new String[shangpinname.length + 1];
			System.arraycopy(shangpinname, 0, newshangpinnames, 0, shangpinname.length);
			shangpinname = newshangpinnames;
			int[] newshangpinnums = new int[shangpinnum.length + 1];
			System.arraycopy(shangpinnum, 0, newshangpinnums, 0, shangpinnum.length);
			shangpinnum = newshangpinnums;
			float[] newshangpinprices = new float[shangpinprice.length + 1];
			System.arraycopy(shangpinprice, 0, newshangpinnames, 0, shangpinprice.length);
			shangpinprice = newshangpinprices;
		}
		shangpinnum[newshangpinNo] = newshangpinnums;
		shangpinname[newshangpinNo] = newshangpinames;
		shangpinprice[newshangpinNo] = newshangpinprice;
		newshangpinNo++; // 瀛樺偍浣嶇疆鎴戜滑鐢ㄤ竴涓澶栫殑涓嬫爣鍙橀噺鏉ユ帶鍒�
		System.out.println("宸叉坊鍔犳垚鍔燂紒\n");
		System.out.println("\t\t\t\t1.杩斿洖涓昏彍鍗�");
		// Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		switch (a) {
		case 1:
			System.out.println("杩斿洖涓昏彍鍗�");
			loadmenu1();
			break;
		default:
			System.out.println("杈撳叆鏈夎璇烽噸鏂拌緭鍏�");
			loadmenu2();
			break;
		}
	}

	// 淇敼鍟嗗搧
	public static void loadmenu3() {
		System.out.print("璇疯緭鍏ヨ淇敼鐨勫晢鍝佺紪鍙�:");
		int shangpinbianhao = SystemIn.nextInt();
		System.out.println("璇疯緭鍏ヤ慨鏀瑰悗鐨勫晢鍝佸悕绉�");
		shangpinname[shangpinbianhao] = newshangpinames;
		SystemIn.nextLong();
		System.out.println("璇疯緭鍏ヤ慨鏀瑰悗鐨勫晢鍝佹暟閲�");
		shangpinnum[shangpinbianhao] = newshangpinnums;
		SystemIn.nextInt();
		System.out.println("璇疯緭鍏ヤ慨鏀瑰悗鐨勫晢鍝佷环鏍�");
		shangpinprice[shangpinbianhao] = newshangpinprice;
		SystemIn.nextFloat();
		System.out.println("宸蹭慨鏀规垚鍔燂紒");
		System.out.println("\t\t\t\t1.杩斿洖涓昏彍鍗�");
		// Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		switch (a) {
		case 1:
			System.out.println("杩斿洖涓昏彍鍗�");
			loadmenu1();
			break;
		default:
			System.out.println("杈撳叆鏈夎璇烽噸鏂拌緭鍏�");
			loadmenu3();
			break;
		}

	}

	// 鍒犻櫎鍟嗗搧
	public static void loadmenu4() {
		loadmenu5();
		System.out.println("璇疯緭鍏ヨ鍒犻櫎鐨勫晢鍝佺紪鍙凤細");
		int shanchubiaohao = SystemIn.nextInt();
		shangpinname[shanchubiaohao - 1] = "";
		shangpinnum[shanchubiaohao - 1] = 2;
		shangpinprice[shanchubiaohao - 1] = 3;
		for (int i = shanchubiaohao; i < newshangpinIndex; i++) {
			shangpinname[i - 1] = shangpinname[i];
			shangpinnum[i - 1] = shangpinnum[i];
			shangpinprice[i - 1] = shangpinprice[i];
		}
		newshangpinIndex--;
		System.out.println("宸插垹闄ゆ垚鍔燂紒");
		loadmenu5();
	}

	// 鏌ョ湅鍟嗗搧
	public static void loadmenu5() {
		System.out.println("***************************鍟嗗搧灞曡瑙堣〃***************************");
		System.out.println("鍟嗗搧缂栧彿" + "\t\t\t鍟嗗搧鍚嶇О " + "\t\t\t鍟嗗搧鏁伴噺 " + "\t\t\t鍟嗗搧浠锋牸 ");
		for (int i = 0; i < shangpinname.length; i++) {
			System.out.println(
					i + 1 + "\t\t\t" + shangpinname[i] + "\t\t\t" + shangpinnum[i] + "\t\t\t" + shangpinprice[i]);
		}
		System.out.println("\t\t\t\t0.杩斿洖涓昏彍鍗�");
		int a = scan.nextInt();
		switch (a) {
		case 0:
			System.out.println("杩斿洖涓昏彍鍗�");
			loadmenu1();
		}
	}

	// 鎼滅储鍟嗗搧
	public static void loadmenu6() {
		System.out.println("璇疯緭鍏ュ晢鍝佸悕绉帮細");
		System.out.println("\t\t\t\t1.杩斿洖涓昏彍鍗�");
		// Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		switch (a) {
		case 1:
			System.out.println("杩斿洖涓昏彍鍗�");
			loadmenu1();
			break;
		default:
			System.out.println("杈撳叆鏈夎璇烽噸鏂拌緭鍏�");
			loadmenu6();
			break;
		}
	}

	// 缁撹处绠$悊
	public static void loadmenu7() {
		System.out.println("娆㈣繋杩涘叆鍟嗚秴璐墿绠$悊绯荤粺锛�");
		System.out.println("\t\t\t\t缁撹处绠$悊");
		System.out.println("****************************************************************");
		System.out.println("\t\t\t\t1.寮�濮嬬粨璐�");
		System.out.println("\t\t\t\t2.鏌ョ湅褰撳ぉ鐨勬秷璐硅褰�");
		System.out.println("\t\t\t\t3.杩斿洖涓昏彍鍗�");
		System.out.println("****************************************************************");
		System.out.println("璇烽�夋嫨锛岃緭鍏ユ暟瀛楁垨鎸�0閫�鍑猴細");
		// Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		/*
		 * switch (a) { case 0: System.out.println("璋㈣阿鎮ㄧ殑浣跨敤!");
		 */
		switch (a) {
		case 1:
			System.out.println("寮�濮嬬粨璐�");
			loadmenu8();
			break;
		case 2:
			System.out.println("鏌ョ湅褰撳ぉ鐨勬秷璐硅褰�");
			break;
		case 3:
			System.out.println("杩斿洖涓昏彍鍗�");
			loadmenu1();
			break;
		default:
			System.out.println("杈撳叆鏈夎璇烽噸鏂拌緭鍏�");
			loadmenu7();
			break;

		}
	}

	// 缁撹处
	public static void loadmenu8() {
		System.out.println("璇疯緭鍏ョ粨璐﹀晢鍝佺殑缂栧彿锛�");
		int shangpinbianhao = SystemIn.nextInt();
		System.out.println("缁撹处鍟嗗搧濡備笅锛�");
		System.out.println(shangpinbianhao + "\t\t\t" + shangpinname[shangpinbianhao] + "\t\t\t"
				+ shangpinnum[shangpinbianhao] + "\t\t\t" + shangpinprice[shangpinbianhao]);
		System.out.println("缁撹处閲戦涓猴細" + shangpinprice[shangpinbianhao]);
		System.out.println("\t\t\t\t1.杩斿洖涓昏彍鍗�");
		// Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		switch (a) {
		case 1:
			System.out.println("杩斿洖涓昏彍鍗�");
			loadmenu1();
			break;
		default:
			System.out.println("杈撳叆鏈夎璇烽噸鏂拌緭鍏�");
			loadmenu8();
			break;
		}
	}
}


网友评论    (发表评论)

共3 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...