• 第九周上机 张垚


     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();
     }
    }
    

      

  • 相关阅读:
    常用工具篇(二)死链接扫描工具–Xenu
    基于python的性能测试工具–locust
    AppServ 8.0 的php 5.6 切换到 php7.0 方法
    toString()和toLocaleString() 的区别
    解决Nginx无法重启问题
    解决 AppServ8.0 安装好之后数据库登陆不上的问题
    TCP/IP 协议
    pc端登陆多个微信
    阿里云服务器创建宝塔面板教程
    轻松免费将你的家庭版windows10升级到windows10专业版
  • 原文地址:https://www.cnblogs.com/ZXCVBNM1314/p/12808960.html
Copyright © 2020-2023  润新知