• java中方法的使用 重载-0512


    class Demo02 
    {
        public static void main(String[] args) 
        {
            System.out.println(add(1,2));
            System.out.println(add(1,2,8));
            System.out.println(add(1.1,2.2));
        }
        public static int add(int a,int b){
               return a+b;
        }
        public static int add(int a,int b,int c){
               return a+b+c;
        }
        public static double add(double a,double b){
               return a+b;
        }
    }
    import java.util.Scanner;
    class Demo01
    {
        public static void main(String[] args) 
        {
            String[] pinpai = {"MacBookAir","ThinkpadT450","ASUS-FL5800"};
            double[] size = {13.0,14.0,15.6};
            double[] price ={6988.88,5999.99,4999.5};
            int[] count = {5,10,18};
            while(true){
                 switch (xz())
                 {
                 case 1:show(pinpai,size,price,count);
                         break;
                 case 2:xg(pinpai,size,price,count);
                         break;
                 case 3:
                     return;
                 default:
                     System.out.println("输入有误");
                         break;
                 
                 }
            }
        }
        public static int xz(){
            System.out.println("1、查看商品库存");
            System.out.println("2、修改库存数量");
            System.out.println("3、退出");
            System.out.println("输入操作编号");
            System.out.println("-----------------------------");
            Scanner sc = new Scanner(System.in);
            int num = sc.nextInt();
            return num;
        }
        
    
        public static void show (String[] pinpai,double[] size,double[] price,int[] count){
            System.out.println("----------------------商城库存清单--------------------");
            System.out.println("品牌型号	尺寸	价格	库存数");
            int csum = 0;
            for(int i=0;i<pinpai.length;i++){
              System.out.println(pinpai[i]+"	"+size[i]+"	"+price[i]+"	"+count[i]);
              csum = csum + count[i];
            }
            System.out.println("库存数	"+csum);
            System.out.println("---------------123------------------");
        }
    
    
    
        public static void xg(String[] pinpai,double[] size,double[] price,int[] count){
            System.out.println("商品编号"+"品牌型号	尺寸	价格	库存数");
            for(int i=0;i<pinpai.length;i++){
              System.out.println(i+"	"+pinpai[i]+"	"+size[i]+"	"+price[i]+"	"+count[i]);
            }
            System.out.println("----------------------------------------------------");
            Scanner sc = new Scanner(System.in);
            System.out.println("输入编号");
            int num = sc.nextInt();
            System.out.println("输入数量");
            int n = sc.nextInt();
            count[num] = n;
        }
    
    }
  • 相关阅读:
    远程诊断DoIP
    基于linux内核包过滤技术的应用网关
    Boost内存池使用与测试
    C++ 编程规范
    大象——Thinking in UML
    C++ 创建类时常考虑的问题
    SLIP—串行线路上传输数据报的非标准协议
    神秘的程序员——编程的乐趣
    Bad Smell (代码的坏味道)
    模式与软件架构——软件架构的非功能特征
  • 原文地址:https://www.cnblogs.com/yelena-niu/p/9035306.html
Copyright © 2020-2023  润新知