zoukankan      html  css  js  c++  java
  • 第九周上机 张垚

     1. package er;
    
    public class point {
    	 int x;
    	    int y;
    	    point() {
    	               
    	    }
    	    point(int dx,int dy) {
    	        x+=dx;
    	        y+=dy;
    	               
    	    }
    	    void movepoint(int p1,int p2) {            
    	        p1=x*2;
    	        p2=y*2;
    	        System.out.println("p1的坐标为"+p1+"
    "+"p2的坐标为"+p2);              
    	    }
    }   
    	 
    package er;
    
    public class person {
    	public static void main(String[] args) {
            point p=new point();
            p.x=6;
            p.y=2;
           p.movepoint(p.x,p.y);
     }
    }
    

      2.

    package er;
    
    public class point {
    	int length;
    	int width;
    
    	point(int width, int length) {
    		this.width = width;
    		this.length = length;
    	}
    
    	void getArea() {
    		System.err.println("面积:"+width*length);
    	}
    
    	void getPer() {
    		System.out.println("周长:"+(width+length)*2);
    	}
    
    	void showAll() {
    		System.out.println("长:"+length+"  宽:"+width);
    	}
    	public static void main(String[] args) {
    		point a = new point(2, 5);
    		a.getArea();
    		a.getPer();
    		a.showAll();
    		
    	}
    }
    

      3.

    package er;
    
    public class point {
    		
    		char color;
    		int cpu;
    
    	    point() {
    	   }
    	     point(char color, int cpu) {
    			this.color = color;
    			this.cpu = cpu;
    		}
    
    	    void point() {
    			System.out.println("颜色:"+color);
    			System.out.println( "型号:"+cpu);
    		}
    	public static void main(String[] args) {
    		point p= new point('p',4689);
    		p.point();
    	   }
    	}
    

      4.

    package test;
    
    public class person {
    	 String name;
    	    double height;
    	    int age;
    	     
    	    public void sayHello(){
    	     System.out.println("hello,my name is " + this.name );
    	    }
    	    public void Value(String name, int age, double height){
    	     this.name = name;
    	     this.age = age;
    	     this.height = height;
    	    }
    	       
    	}
    package test;
    
    public class personcreate {
    	public static void main(String[] args) {
            // TODO Auto-generated method stub
            person p1 = new  person();
            p1.Value("zhangsan",33,1.74);
            p1.sayHello();
            person p2 = new  person();
            p2.Value("lishi",44,1.74);
            p2.sayHello();
     }
    }
    

      

  • 相关阅读:
    [总结]并查集
    一些麻烦的语法知识
    P1496 找筷子
    P1314 [NOIP2011 提高组] 聪明的质监员
    HDU 1232 -畅通工程(并查集)
    POJ 1611 -The Suspects (并查集)
    方框(HPU暑期第四次积分赛)
    HDU 2191
    B
    HDU 1009
  • 原文地址:https://www.cnblogs.com/ZXCVBNM1314/p/12808960.html
Copyright © 2011-2022 走看看