zoukankan      html  css  js  c++  java
  • 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;
        }
    
    }
  • 相关阅读:
    mysql代码实现hive中的rank()排序方法,获得top3中的最小值
    MySQL--Hive中字段数据类型对比
    使用shell脚本连接mysql shell脚本执行mysql语句
    WPS中查看超链接后返回超链接位置
    shell脚本中常用的命令
    Lamda一行代码实现"36选7"随机自动选号
    创建Visual studio项目模板 vstemplate关键点纪要
    网络传输及数据解析
    动画
    触摸事件与手势识别
  • 原文地址:https://www.cnblogs.com/yelena-niu/p/9035306.html
Copyright © 2011-2022 走看看