- package kao;
- public class Main
- {
- public static void main(String[] args)
- {
- Family dad = new Family();
- dad.people="爸爸";
- dad.age=40;
- dad.hobby="爬山";
- System.out.printf("%s今年%d歲,喜歡%s\r\n",dad.people,dad.age,dad.hobby);
- Family mom = new Family();
- mom.people="媽媽";
- mom.age=37;
- mom.hobby="逛街";
- System.out.printf("%s今年%d歲,喜歡%s\r\n",mom.people,mom.age,mom.hobby);
- Family boy = new Family();
- boy.people="男孩";
- boy.age=10;
- boy.hobby="打電動";
- System.out.printf("%s今年%d歲,喜歡%s\r\n",boy.people,boy.age,boy.hobby);
- Family girl = new Family();
- girl.people="女孩";
- girl.age=8;
- girl.hobby="看書";
- System.out.printf("%s今年%d歲,喜歡%s\r\n",girl.people,girl.age,girl.hobby);
- }
- }
複製代碼 |