作者pelicanper (派立肯)
看板java
标题Re: [问题] 新手继承问题(非作业)
时间Sat Oct 20 17:31:25 2012
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)
1F:推 TWTRubiks:哇~! 都是英文~! 有得看了 10/20 22:04