zoukankan      html  css  js  c++  java
  • JAVA-1.5-homework

    package study;//创建类
    /*
     * 定义一个矩形类Rectangle:(知识点:对象的创建和使用)
     *1 定义三个方法:getArea()求面积、getPer()求周长,showAll()分别在控制台输出长、宽、面积、周长。
     *2 有2个属性:长length、宽width
     *3 创建一个Rectangle对象,并输出相关信息
     */
    public class Rectangle {
        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 study;//创建类
    /*
     * 定义一个矩形类Rectangle:(知识点:对象的创建和使用)
     *1 定义三个方法:getArea()求面积、getPer()求周长,showAll()分别在控制台输出长、宽、面积、周长。
     *2 有2个属性:长length、宽width
     *3 创建一个Rectangle对象,并输出相关信息
     */
    public class Rectangle {
        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);
            System.out.println("面积是:"+length*width);
            System.out.println("周长是:"+(length+width)*2);
        }
    }
    package study;//创建对象
    
    public class homework {
        public static void main(String[] args) {
            Rectangle Rectangle=new Rectangle();
            Rectangle.length=3;
            Rectangle.width=4;
            Rectangle.showAll();
        }
    }
    //运行结果
  • 相关阅读:
    用initconnect+binlog实现用户操作追踪【转】
    INSERT INTO … SELECT 的锁【转】
    Memcached 高可用方案 Repcached
    关于MySQL建表对DML的影响【转】
    NoSQL之【memcached】学习
    关于MySQL insert into ... select 的锁情况
    MySQL数据库诊断——InnoDB关机问题 【转】
    Your document is being created
    Failure to Get Sequential Numbering Profile Option
    Runtime error '1004'
  • 原文地址:https://www.cnblogs.com/yunlan/p/12733178.html
Copyright © 2011-2022 走看看