zoukankan      html  css  js  c++  java
  • 第九周上机练习

    1.

    package LH;
    public class Point {
            int x;
            int y;
    
            Point() {
    
            }
    
            Point(int x0, int y0) {
                this.x = x0;
                this.y= y0;
            }
            
            void movePoint(int dx,int dy) {
                this.x += dx;
                this.y += dy;
                
            }
        }
    package LH;
    public class Test {
        public static void main(String[] args) {
            Point p1 = new Point(1, 1);
            p1.movePoint(2, 2);
            System.out.println("p1当前的X坐标为:" + p1.x + ",p1当前的Y坐标为:" + p1.y);
            Point p2 = new Point(1,1);
            p2.movePoint(3, 3);
            System.out.println("p2当前的X坐标为:" + p2.x + ",p2当前的Y坐标为:" + p2.y);
    
        }
    }

    2.

    package LH;
    
    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 showAll() {
            System.out.println("长:" + length);
            System.out.println("宽:" + width);
            System.out.print("面积:");
            getArea();
            System.out.print("周长:");
            getPer();
        }
    
        public Rectangle(int width, int length) {
            this.length = length;
            this.width = width;
        }
    
    }
    package LH;
    
    public class Text {
        public static void main(String[] args) {
            Rectangle rc = new Rectangle(3, 5);
            rc.showAll();
        }
    }

    3.

    package LH;
    
    public class Com {
           char color;
            String cpu;
            public bjb() {
                System.out.println("无参数");
            }
            public bjb(char a,String b) {
                color=a;
                cpu=b;
                System.out.println(color);
                System.out.println(cpu);
                System.out.println("有参数");
            }
            public void sj(){
                System.out.println("颜色是"+color);
                System.out.println("cpu"+cpu);
            } 
    }
    package LH;
    
    public class Test {
        public static void main(String[] args) {
                bjb b1=new  bjb();
                bjb b2=new  bjb('白',"i7");
                b2.sj();
            }
    
        }

    6.

    package LH;
    
    public class Preson {
            String name;
            int age;
            double height;
            public void sayHello(){
                System.out.println("hello,my name is "+this.name);
            }
            public void getValue(String name,int age,double height){
                this.name = name;
                this.age = age;
                this.height = height;
            }
        }
    package LH;
    
    public class Test {
    
        public static void main(String[] args) {
            Person p1 = new Person();
            p1.getValue("zs",25,1.85);
            p1.sayHello();
            Person p2 = new Person();
            p2.getValue("ls",35,1.75);
            p2.sayHello();
            }
        }
  • 相关阅读:
    单点登录cas常见问题(八)
    11G新特性 -- variable size extents
    11G新特性 -- ASM Fast Mirror Resync
    redhat 6.4 安装VirtualBox自动增强功能功:unable to find the sources of your current Linux kernel
    LINUX使用DVD光盘或者ISO作为本地YUM源
    数据库报ORA-00600: 内部错误代码, 参数: [17059],并产生大量trace日志文件
    Putty设置删除
    ssh/scp 远程连接ssh非默认端口方法
    查看LINUX版本
    RHCE7 -- systemctl命令
  • 原文地址:https://www.cnblogs.com/z118127/p/12808819.html
Copyright © 2011-2022 走看看