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

📄 remove.java

📁 电子商店
💻 JAVA
字号:
/**
 * 
 */
package product;
/**
 * @author 韦建艺 0658025
 * @2008.11.04
 * @
 */
import java.io.*;

public class Remove {//KO!!!

	public void Remove(String str[][], double arr1[][], int arr2[][]) {
		// ID, Str, Double, Int
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		System.out
				.println("What kind of product's category do you want to Remove");
		System.out.println("Cin C: computer");
		System.out.println("Cin S:  software");
		System.out.println("Cin O: stereo");
		String s = null;
		String name = null;
		try {
			String anString = in.readLine();
			s = anString;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if (s.equals("C")) {
			System.out.println("So you want to remove a computer product");
			System.out.println("What's the name of the computer?");
			try {
				String anString = in.readLine();
				name = anString;
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

			for (int i = 0; i < str.length; i++) {
				if (str[i][0] == null) {
					break;
				} else {
					if (str[i][0].equals("computer") && str[i][1].equals(name)) {
						for (int k = i; k < str.length; k++) {// 后面向前移动覆盖要删除的
							if (str[k][0] == null) {
								break;
							} else {
								for (int j = 0; j < 7; j++) {
									str[k][j] = str[k + 1][j];// java.lang.ArrayIndexOutOfBoundsException:
									// 100
									arr2[k][j] = arr2[k + 1][j];
									if (j < 4) {
										arr1[k][j] = arr1[k + 1][j];
									}
								}
							}
						}
						System.out.println("A computer has been remove");
						System.out.println();
					}
				}
			}
		} else if (s.equals("S")) {
			System.out.println("So you want to remove a software product");
			System.out.println("What's the name of the software?");
			try {
				String anString = in.readLine();
				name = anString;
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			for (int i = 0; i < str.length; i++) {
				if (str[i][0] == null) {
					break;
				} else {
					if (str[i][0].equals("software") && str[i][1].equals(name)) {
						for (int k = i; k < str.length; k++) {// 后面向前移动覆盖要删除的
							if (str[k][0] == null) {
								break;
							} else {
								for (int j = 0; j < 7; j++) {
									str[k][j] = str[k + 1][j];
									arr2[k][j] = arr2[k + 1][j];
									if (j < 4) {
										arr1[k][j] = arr1[k + 1][j];

									}
								}
							}
						}
						System.out.println("A software has been remove");
						System.out.println();
					}
				}
			}
		} else if (s.equals("O")) {
			System.out.println("So you want to remove a stereo product");
			System.out.println("What's the name of the stereo?");
			try {
				String anString = in.readLine();
				name = anString;
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			for (int i = 0; i < str.length; i++) {
				if (str[i][0] == null) {
					break;
				} else {

					if (str[i][0].equals("stereo") && str[i][1].equals(name)) {
						for (int k = i; k < str.length; k++) {// 后面向前移动覆盖要删除的
							if (str[k][0] == null) {
								break;
							} else {
								for (int j = 0; j < 7; j++) {
									str[k][j] = str[k + 1][j];
									arr2[k][j] = arr2[k + 1][j];
									if (j < 4) {
										arr1[k][j] = arr1[k + 1][j];

									}
								}
							}
						}
						System.out.println("A strereo has been remove");
						System.out.println();
					}
				}
			}
		} else {
			System.out
					.println("Your selection is not right,So sorry!");
			System.out.println();
		}
	}
}

⌨️ 快捷键说明

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