⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rectangle.java

📁 继承和多态 实验目的: 1、 掌握继承和多态的概念与实现方法 2、 掌握如何从已有的类中派生子类并继承父类 3、 掌握方法的覆盖和重载 实验内容: 设计一个通用的排序算法
💻 JAVA
字号:
package generalSort;

/**
 * <p>Title: Rectangle</p>
 *
 * <p>Description: A simple class to describ a rectangle, which has two properties and two methods
 *
 ****Property Len represents the length of a rect
 ****Property WIdth represents the width of a rect
 ****Method int area() returns the area of a rect with properties Len & Width
 ****Method String toString() returns the description of a rect with properties Len & Width & its area
 *
 * </p>
 * <p>Copyright: Copyright (c) 2008 All rights reserved</p>
 * <p>Organization:Shandong University </p>
 * @Email:ruohanxiao@yahoo.com.cn
 * @author: Xiao Ruohan
 * @version 1.0
 */
public class Rectangle {
    private int Len;
    private int Width;

    public Rectangle() {
    }

    public Rectangle(int len, int width) {
        this.Len = len;
        this.Width = width;
    }

    public int area() {
        return this.Len * this.Width;
    }

    public String toString() {
        return "The current rectangle's length, width, and area is " + this.Len +
                StringPlus.blanks(String.valueOf(this.Len), 5) + this.Width +
                StringPlus.blanks(String.valueOf(this.Width), 5) + this.area();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -