zoukankan      html  css  js  c++  java
  • 测试与封装

    public class test {
        private int a;
        private int b;
        int c;
        public int  add(int a,int b)
        {
        
            System.out.println(""+a);
            System.out.println(""+b);
            c = a+b;
            System.out.println("a+b="+(a+b)+"
    ");
            return c;
            
        }
        public int  jian(int a,int b)
        {
            
            System.out.println(""+a);
            System.out.println(""+b);
            c=a-b;
            System.out.println("a-b="+(a-b)+"
    ");
            return c;
            
            
        }
        public int Cheng(int a,int b)
        {   
            System.out.println(""+a);
            System.out.println(""+b);
            c=a*b;
            System.out.println("a*b="+(a*b)+"
    ");
            return c;
        }
        public double  Chu(int a,int b)
        {
            double c;
            c=(double) (Math.round((a/b)*100/100.0));
            System.out.println(""+a);
            System.out.println(""+b);
            if(b!=0)
                System.out.println("c=a/b="+(c)+"
    ");
            else
                throw new ArithmeticException();
                System.out.println("分母不能为0!");
                  
                return c;
        }
    
        /**
         * @param args
         */
        public static void main(String[] args) {
             Test Jia=new Test();
             Jia.jia(1, 1);
             Test Jian=new Test();
             Jian.jian(2,1);
             Test cheng=new Test();
             cheng.Cheng(2,3);
             Test chu=new Test();
             chu.Chu(3,0);
             
        }
  • 相关阅读:
    安全和加密
    awk
    CentOS7练习
    CentOS7系统引导顺序以及排障
    网络配置
    RAID阵列搭建
    LVM逻辑卷
    java-web——第九课 request
    java-web——第八课 JSTL的显示格式
    java-web——第七课 JSTL
  • 原文地址:https://www.cnblogs.com/LANG-langlanglang/p/4485565.html
Copyright © 2011-2022 走看看