zoukankan      html  css  js  c++  java
  • 4月30号作业

    1.

    package hello;
    
    public class yes {
        
    
            private int x0;
            private int y0;
            public yes(){
            
            }
            public yes(int x0,int y0) {
                this.x0=x0;
                this.y0=y0;
            }
            public void point1(){
                System.out.println("无参构造("+x0+","+y0+")");
            }
            public void movepoint(int dx,int dy){
                System.out.println("坐标是:("+dx+","+dy+")");
            }
        }
    package hello;
    
    public class text {
    public static void main(String[] args) {
    yes p1=new yes();
    p1.movepoint(3, 4);
    yes p2=new yes();
    p2.movepoint(5, 8);
    yes p3=new yes(12,34);
    p3.point1();
    }
    }

    2.

    package hello;
    
    public class yes {
        
        double length;
        double 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);
            getArea();
            getPer();
        }
    }
    package hello;
    import java.util.Scanner;
    public class text {
    public static void main(String[] args) {
        try (Scanner input = new Scanner(System.in)) {
            yes r = new yes();        
            System.out.println("请输入长方形的长:");
            r.length = input.nextInt();
            System.out.println("请输入长方形的宽:");
            r.width = input.nextInt();
            r.getArea();
            r.getPer();
            r.showAll();
        }
    }
    }

    3.

    package hello;
    
    public class yes {   
        
    char color;
    int cpu;
    yes() {
    
    }
    yes(char color, int cpu) {
        this.color = color;
        this.cpu = cpu;
    }
    void a() {
        System.out.println("颜色:" + color + "  型号:" + cpu);
    }
    }
    package hello;
    
    public class text {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        yes a = new yes('s', 18928888);
        a.a();
    }
    }

    4.

    package hello;
    
    public class Person {
        String name;// 姓名
        double height;// 身高
        double age ;// 年龄
        Person(String name, double height, double age) {
            this.name = name;
            this.height = height;
            this.age = age;
        }
        void sayHello() {
            System.out.println("hello,my name is  " + name+" "+height+"m"+" "+age+"");
        }
    
    }
    package hello;
    
    public class text {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Person a = new Person("zhangsan", 1.73, 33);
        Person b = new Person("lishi", 1.74, 44);
        a.sayHello();
        b.sayHello();
    }
    }
  • 相关阅读:
    request和request.form和request.querystring的区别
    VS2010中如何创建一个WCF
    ASP.Net MVC 3.0 之 MVCContrib的使用
    C# 请假小时数的计算(完整代码)
    C#调用WebService
    .Net Framework 框架工作原理
    做程序员的感悟
    WCF入门简单教程(图文) VS2010版
    仿淘宝的浮动工具栏(兼容IE6和其他浏览器)
    (原创)LINQ To SQL简单入门
  • 原文地址:https://www.cnblogs.com/cmk521/p/12808186.html
Copyright © 2011-2022 走看看