zoukankan      html  css  js  c++  java
  • javase 超市库存系统

    package com.oracle.demo01;
    
    import java.util.ArrayList;
    import java.util.Scanner;
    
    public class Demo01 {
        public static void main(String[] args) {
            System.out.println("=========================欢迎光临   oracle 超市======================");
            System.out.println("1:货物清单 2:添加新货物 3:删除货物 4:修改货物");
            System.out.println("5:退出系统");
            System.out.println("请您输入要操作的功能序号");        
            System.out.println("--------------");
            while(true){
                System.out.println("1:货物清单 2:添加新货物 3:删除货物 4:修改货物");
                System.out.println("5:退出系统");
                System.out.println("请您输入要操作的功能序号");
                Scanner sc = new Scanner(System.in);
                int num = sc.nextInt();
                switch (num) {
                case 1:
                    f1();
                    break;
                case 2:
                    f2();
                    break;
                case 3:
                    f3();
                    break;
                case 4:
                    f4();
                    break;
                case 5:
                    return;
                default:
                    System.out.println("您输入的有误");
                    break;
                }
            }
            
        }
    
        
    
        public static void f1() {
            ArrayList<chaoshi> arr = new ArrayList<chaoshi>();
            chaoshi c1 = new chaoshi();
            c1.spbh = 9001;
            c1.spm = "少林寺酥饼核桃";
            c1.jiage = 120.0;
            arr.add(c1);
            chaoshi c2 = new chaoshi();
            c2.spbh = 9002;
            c2.spm = "尚康杂粮牡丹饼";
            c2.jiage = 20.0;
            arr.add(c2);
            chaoshi c3 = new chaoshi();
            c3.spbh = 9003;
            c3.spm = "新疆原产哈密瓜";
            c3.jiage = 7.0;
            arr.add(c3);
            System.out.println("商品编号" + "	" + "商品名称" + "	" + "	" + "商品单价");
            for (int i = 0; i < arr.size(); i++) {
                System.out.println(arr.get(i).spbh + "	" + arr.get(i).spm + "	" + arr.get(i).jiage);
            }
        }
    
        public static void f2() {
            ArrayList<chaoshi> arr = new ArrayList<chaoshi>();
            chaoshi c4 = new chaoshi();
            System.out.println("输入新水果的名称:");
            Scanner mz = new Scanner(System.in);
            String sg = mz.next();
            c4.spm = sg;
            System.out.println("输入新水果的编号:");
            int sg1 = mz.nextInt();
            c4.spbh = sg1;
            System.out.println("输入新水果的价格:");
            int sg2 = mz.nextInt();
            c4.jiage = sg2;
            arr.add(c4);
            chaoshi c1 = new chaoshi();
            c1.spbh = 9001;
            c1.spm = "少林寺酥饼核桃";
            c1.jiage = 120.0;
            arr.add(c1);
            chaoshi c2 = new chaoshi();
            c2.spbh = 9002;
            c2.spm = "尚康杂粮牡丹饼";
            c2.jiage = 20.0;
            arr.add(c2);
            chaoshi c3 = new chaoshi();
            c3.spbh = 9003;
            c3.spm = "新疆原产哈密瓜";
            c3.jiage = 7.0;
            arr.add(c3);
            System.out.println("商品编号" + "	" + "商品名称" + "	" + "	" + "商品单价");
            for (int i = 0; i < arr.size(); i++) {
                System.out.println(arr.get(i).spbh + "	" + arr.get(i).spm + "	" + arr.get(i).jiage);
            }
        }
    
        public static void f3() {
            System.out.println("输入您要删除的商品编号");
            Scanner sc = new Scanner(System.in);
            int sc1 = sc.nextInt();
            ArrayList<chaoshi> arr = new ArrayList<chaoshi>();
            chaoshi c1 = new chaoshi();
            c1.spbh = 9001;
            c1.spm = "少林寺酥饼核桃";
            c1.jiage = 120.0;
            arr.add(c1);
            chaoshi c2 = new chaoshi();
            c2.spbh = 9002;
            c2.spm = "尚康杂粮牡丹饼";
            c2.jiage = 20.0;
            arr.add(c2);
            chaoshi c3 = new chaoshi();
            c3.spbh = 9003;
            c3.spm = "新疆原产哈密瓜";
            c3.jiage = 7.0;
            arr.add(c3);
            if (sc1 == 9001) {
                arr.remove(0);
            }
            if (sc1 == 9002) {
                arr.remove(1);
            }
            if (sc1 == 9003) {
                arr.remove(2);
            }
            System.out.println("商品编号" + "	" + "商品名称" + "	" + "	" + "商品单价");
            for (int i = 0; i < arr.size(); i++) {
                System.out.println(arr.get(i).spbh + "	" + arr.get(i).spm + "	" + arr.get(i).jiage);
            }
        }
    
        public static void f4() {
            ArrayList<chaoshi> arr = new ArrayList<chaoshi>();
            chaoshi c1 = new chaoshi();
            c1.spbh = 9001;
            c1.spm = "少林寺酥饼核桃";
            c1.jiage = 120.0;
            arr.add(c1);
            chaoshi c2 = new chaoshi();
            c2.spbh = 9002;
            c2.spm = "尚康杂粮牡丹饼";
            c2.jiage = 20.0;
            arr.add(c2);
            chaoshi c3 = new chaoshi();
            c3.spbh = 9003;
            c3.spm = "新疆原产哈密瓜";
            c3.jiage = 7.0;
            arr.add(c3);
            System.out.println("输入您要修改的商品编码:");
            Scanner xg = new Scanner(System.in);
            int g1 = xg.nextInt();
            System.out.println("输入新的商品编码");
            int g2 = xg.nextInt();
            System.out.println("输入新的水果名称");
            String g3 = xg.next();
            System.out.println("输入新的水果价格");
            int g4 = xg.nextInt();
            if (g1 == 9001) {
                c1.spbh = g2;
                c1.spm = g3;
                c1.jiage = g4;
            }
            if (g1 == 9002) {
                c2.spbh = g2;
                c2.spm = g3;
                c2.jiage = g4;
            }
            if (g1 == 9003) {
                c3.spbh = g2;
                c3.spm = g3;
                c3.jiage = g4;
            }
            System.out.println("商品编号" + "	" + "商品名称" + "	" + "	" + "商品单价");
            for (int i = 0; i < arr.size(); i++) {
                System.out.println(arr.get(i).spbh + "	" + arr.get(i).spm + "	" + arr.get(i).jiage);
            }
        }
    }
  • 相关阅读:
    Codeforces 1062
    HDU 1247
    力扣 7. 整数反转
    力扣 3. 无重复字符的最长子串
    力扣1. 两数之和
    力扣 78.子集
    C++编译时报错“count”符号不明确
    Java邻接矩阵存储图简易版以及深度优先优先遍历和广度优先遍历
    word中超链接显示成{HYPERLINK "url"}形式的解决方案
    Hadoop在window上运行出现:java.io.IOException: (null) entry in command string: null chmod 0644
  • 原文地址:https://www.cnblogs.com/hankai2735/p/9046903.html
Copyright © 2011-2022 走看看