返回列表 發帖
  1. package bn.tw;

  2. public class Dog {
  3.         String name;
  4.         int age;
  5.         double weight;
  6.         String color;

  7.         public Dog(String name, int age, double weight, String color) {
  8.                 this.name = name;
  9.                 this.age = age;
  10.                 this.weight = weight;
  11.                 this.color = color;
  12.         }

  13.         public void showProfile() {
  14.                 System.out.println(String.format("%s今年%d歲,體重%f公斤,毛色是%s色"));
  15.         }
  16. }
複製代碼

TOP

返回列表