你的位置:首页 > 软件开发 > Java > java之前往对象村

java之前往对象村

发布时间:2016-09-07 19:00:09
这次说一说面向对象与面向过程的区别以及面向对象的优点。听一听用面向过程思想编程的程序员写程序时的心声:What are the things this program has to do? What procedures do we need?啊哈,作为一名合格的准java程序员 ...

这次说一说面向对象与面向过程的区别以及面向对象的优点。


java之前往对象村

  // make the shape rotate 360º

}

playSound(shapeNum) {

  // use shapeNum to lookup which

     // AIF sound to play, and play it

 

 

}

 

 

我思考很久,也找到了其中的类:图形。(哈哈)

继续按着面向对象的思想思索,这个类有什么属性呢?需求里没提吧。类的行为呢?有旋转,和放音乐的行为。嗯,分析完就写程序啦。

class cirlce {

  ratate() {

    //code to ratate a circle

     }

  playSound() {

    //code to ratate a circle

  }

}

 

class Square {

 

  ratate() {

 

    //code to ratate a circle

 

     }

 

  playSound() {

 

    //code to ratate a circle

 

  }

 

 

 

 

 

 

 

 

 

 

现在项目经理说需求有变

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

面向对象三大特性中的:继承,多态,让代码的复用率提高了老多。

面向对象优点非常非常的多,自己可以去深深体验一下,编程学习中自己尝试是非常非常重要的。


 

一个小建议:

If you’re stuck on an exercise, try talking about it out loud. Speaking (and hearing) activates a different part of your brain. Although it works best if you have another person to discuss it with, pets work too. That’s how our dog learned polymorphism.

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:java之前往对象村

关键词:JAVA

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。