import java.util.Scanner;
import java.util.Random;
class kuCun
{
    public static void main(String[] args)
    {
        //库存管理:封装:
        String[][] list={{"电视机","3"},{"洗衣粉","8"},{"食用盐","5"},{"口香糖","10"}};
        Scanner sc=new Scanner(System.in);

        aa:while(true){
        System.out.println("---------库存管理---------");
        System.out.println("1.查看库存清单");
        System.out.println("2.修改商品库存数量");
        System.out.println("3.退出");
        System.out.println("--------------------------");
        System.out.println("请输入要执行的操作序号:");
            int in=sc.nextInt();
            switch(in){
            case 1:
                look(list);
            break;
            case 2:
                select(list);
            break;
            case 3:
                break aa;
            default:
                System.out.println("--------------------------");
                System.out.println("请输入正确的操作序号!");
                System.out.println("--------------------------");
            break;
            }
        }
    }
    //打印库存清单功能
    public static void look(String[][] list){
        for(int i=0;i<list.length;i++){
            for(int j=0;j<list[i].length;j++){
                if(j==0){
                    System.out.print("商品名称:"+list[i][j]+"   ");
                }else if(j==1){
                    System.out.print("库存数量:"+list[i][j]);
                }
            }
            System.out.println();
        }
    }
    //库存商品数量修改功能
    public static void select(String[][] list){
        System.out.println("请输入您要修改的商品序号");
        for(int i=0;i<list.length;i++){
            System.out.print((i+1)+":"+list[i][0]);
            System.out.println();
        }
        Scanner sc=new Scanner(System.in);
        int in=sc.nextInt();
    bb:while(true){
            switch(in){
            case 1:
                System.out.println("商品名称为:"+list[in-1][0]);
                System.out.println("请修改库存数量");
                String add=sc.next();
                list[in-1][1]=add;
                System.out.println("修改后"+list[in-1][0]+"的库存为:"+add);
                System.out.println();
                break bb;
            case 2:
                System.out.println("商品名称为:"+list[in-1][0]);
                System.out.println("请修改库存数量");
                add=sc.next();
                list[in-1][1]=add;
                System.out.println("修改后"+list[in-1][0]+"的库存为:"+add);
                System.out.println();
                break bb;
            case 3:
                System.out.println("商品名称为:"+list[in-1][0]);
                System.out.println("请修改库存数量");
                add=sc.next();
                list[in-1][1]=add;
                System.out.println("修改后"+list[in-1][0]+"的库存为:"+add);
                System.out.println();
                break bb;
            case 4:
                System.out.println("商品名称为:"+list[in-1][0]);
                System.out.println("请修改库存数量");
                add=sc.next();
                list[in-1][1]=add;
                System.out.println("修改后"+list[in-1][0]+"的库存为:"+add);
                System.out.println();
                break bb;
            case 00:
                break bb;
            default:
                System.out.println("请输入正确的商品序号");
                in=sc.nextInt();
                break;
            }
        }
    }
}
12-20 12:20