zoukankan      html  css  js  c++  java
  • Java上机作业4.30

    package ak;
    
    public class Point {
    	int x;
    	int y;
    
    	void Ponit() {
    		System.out.println(x);
    		System.out.println(y);
    
    	}
    
    	void Ponit(int x0, int y0) {
    		x = x0;
    		y = y0;
    	}
    
    	void movePonit(int dx, int dy) {
    		x += dx;
    		y += dy;
    		System.out.println("坐标是" + "(" + x + "," + y + ")");
    	}
    	public static void main(String[] args) {
    		Point p1 = new Point();
    		p1.x=1;
    		p1.y=2;
    		p1.movePonit(3, 4);
    		Point p2 = new Point();
    		p2.x=11;
    		p2.y=23 ;
    		p2.movePonit(3,9);
    	}
    }
    	
    

      

    package ak;
    
    
    public class Rectangle {
    	int length;
    	int width;
    
    	public void getArea() {
    		System.out.println(length * width);
    	}
    
    	public void getPer() {
    		System.out.println((length + width) * 2);
    	}
    
    	public void getAll() {
    		System.out.println("长是" + length);
    		System.out.println("宽是" + width);
    		System.out.println("面积是");
    		getArea();
    		System.out.println("周长是");
    		getPer();
    	}
    	void Rectangle(int width1, int length1){
    		length=length1;
    		width=width1;
    		getAll();
    		
    	}
    	public static void main(String[] args) {
    		Rectangle r1 = new Rectangle();
    		r1.Rectangle(4, 6);
    		
    	}
    
    }
    

      

    package ak;
    
    public class Book {
    	static int cpu;
    	static char color;
    
    	public static void all() {
    		System.out.println("颜色是" + color);
    		System.out.println("cpu是" + cpu);
    	}
    
    	static void book(int cpu1, char color1) {
    		cpu = cpu1;
    		color = color1;
    		all();
    	}
    
    	public static void main(String[] args) {
    		Book r1 = new Book();
    		r1.color = '黑';
    		r1.cpu = 9100;
    		r1.all();
    		book(9000, '白');
    
    	}
    }
    

      

    package www;
     
    public class Person {
     
        double height;
        int age;
        String name;
     
        public void sayHello() {
            System.out.println("Hello,my name is "+name);
        }
     
    }
    package www;
     
    public class PersonCreate {
     
        public static void main(String[] args) {
            Person p1=new Person();
            p1.age=34;
            p1.height=1.73;
            p1.name="zhangsan";
            p1.sayHello();
            Person p2=new Person();
            p2.age=44;
            p2.height=1.74;
            p2.name="lishi";
            p2.sayHello();
        }
     
    }
    

      

  • 相关阅读:
    居中
    背景和内容
    Filter 解决web网页跳转乱码
    java内部类
    javascript 基础教程[温故而知新一]
    每隔一秒自动执行函数(JavaScript)
    详解 Android Activity 生命周期
    css 重新学习系列(3)
    css 重新学习系列(2)
    写一个迷你版Smarty模板引擎,对认识模板引擎原理非常好(附代码)
  • 原文地址:https://www.cnblogs.com/hzpiou/p/12807712.html
Copyright © 2011-2022 走看看