[Java] 继承与多态 →→→→→进入此内容的聊天室

来自 , 2020-08-06, 写在 Java, 查看 135 次.
URL http://www.code666.cn/view/ce5140df
  1. package trangle;
  2.  
  3. public class juxing implements Printable{
  4.         private int width;
  5.         private int height;
  6.        
  7.         public juxing(int width, int height) {
  8.                 this.width = width;
  9.                 this.height = height;
  10.         }
  11.        
  12.         public int area() {
  13.                 return width * height;
  14.         }
  15.        
  16.         public int length() {
  17.                 return 2 * (width + height);
  18.         }
  19.        
  20.         public void printWay() {
  21.                 System.out.println("矩形面积 : "+area()+"\n矩形周长 : "+length());
  22.         }
  23.        
  24.         public void printWay(char c) {
  25.                 for (int i = 0; i < width; i++) {
  26.                         for (int j = 0; j < height; j++) {
  27.                                 System.out.print(c);
  28.                         }
  29.                         System.out.println();
  30.                 }
  31.         }
  32. }

回复 "继承与多态"

这儿你可以回复上面这条便签

captcha