Re: [問題] 新手繼承問題(非作業)

看板java作者 (派立肯)時間13年前 (2012/10/20 17:31), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/4 (看更多)
Just some suggestions... 1. The Person class should be abstract, so your sub-classess can inherit all characters from parent class without distroying data. 2. Because you have private fields in your parent classes, you should have "gettters" for each variables. In you codes, you only have getter for name, not ID. What happen if you only need ID? 3. In the theory of inheritace on JAVA language, you can say a "student" is a person. Therefore, you can just create a new student instance, without create a person instance. That is another reason you have a abstract class for person because every student is a person. 4. In program design of reality, It's much better if you use methods in printing information. It means you only call other methods when you want to output some information, so you just need to modity your information resource method rather than print method. It helps your program become scalable and flexible. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 27.252.20.46 ※ 編輯: pelicanper 來自: 27.252.20.46 (10/20 17:45)

10/20 22:04, , 1F
哇~! 都是英文~! 有得看了
10/20 22:04, 1F
文章代碼(AID): #1GWcznR2 (java)
文章代碼(AID): #1GWcznR2 (java)