zoukankan      html  css  js  c++  java
  • java基础_类和对象.—5

    首先,编写一个类ChongZai,该类中有3个重载的方法void print();其次,

    再编写一个主类来测试ChongZai类的功能。

    public class Chongzai1 {
    //	首先,编写一个类ChongZai,该类中有3个重载的方法void print();其次,
    //	再编写一个主类来测试ChongZai类的功能。
    	int a,b,c;
    	
    	
    	public int getA() {
    		return a;
    	}
    	public void setA(int a) {
    		this.a = a;
    	}
    	public int getB() {
    		return b;
    	}
    	public void setB(int b) {
    		this.b = b;
    	}
    	public int getC() {
    		return c;
    	}
    	public void setC(int c) {
    		this.c = c;
    	}
    	public double add (double a,double b)
    	
    	{
    		return(a+b);
    	}
    	public double add (double a,double b,double c)
    	
    	{
    		return (add(a, b)+c);
    	}
    	public double ji(double a,double b)
    	{
    		return a*b;
    	}
    	public double ji(double a,double b,double c)
    	{
    		return ji(a,b)*c;
    	}
    	public double h(double a,double b,double c)
    	{
    		return ji(a,b)+c;
    	}
    	
    	
    	
    	public static void main(String [] args)
    	   {
    		   Chongzai1 c=new Chongzai1();
    		 
    		   System.out.println(c.add( 3, 4));
    		   
    		   System.out.println(c.add(3, 4, 5));
    		   
    		   System.out.println(c.ji(3, 4));
    		   
    		   System.out.println(c.ji(3, 4, 5));
    		   
    		   System.out.println(c.h(3, 4, 5));
    	   }
    }
    
      
    

     

  • 相关阅读:
    文件权限
    文件权限
    Nginx SSL/HTTPS 配置
    Nginx SSL/HTTPS 配置
    Nginx SSL/HTTPS 配置
    安装opencv3.3.0方法
    安装opencv3.3.0方法
    安装opencv3.3.0方法
    安装opencv3.3.0方法
    阿里巴巴的体量到底有多大?
  • 原文地址:https://www.cnblogs.com/jakeasd/p/5512645.html
Copyright © 2011-2022 走看看