The Program Extention

原创 2004年08月18日 22:06:00

Problem Description:

                A manufactured item can have one of the solid shapes cone,
                cylinder or rectangle and can be made from one of a number of
                materials, such as plastic or metal. Write a program to input
                the density of the material and the shape and dimensions of the
                item and to display the weight of the item.(Hint: Different
                shapes will require different dimensions to be input and
                different calculations to be performed to calculate the volume.
                Firstly, ask the user to specify the shape, and then use a
                switch statement to allow the program to perform input and
                calculations specific to that shape.)

My Opinoin:

     Shall I use a structure to store the item information? For example, store the length, width and height of a rectangle, even the equation to calculating the weight. That will have a good extention.
     However, the problem is that the elements of the structure is changable. For example, a cyclinder has only two element: radius and height to calculate its cubage while a rectangle needs three: length, width, height. How can I solve this problem?
     If the problem is solved, there is no need to modify the code when a new item is added. Otherwise, we have no choice but to rewrite the code.
     Which way should I follow?

TimWang - China

August 18,2004

掌握 VSCode IDE 编辑器【专家辅导】

掌握 Visual Studio Code IDE 编辑器的使用,这一微软开发的,开源项目。 【办理终身会员】http://edu.csdn.net/lecturer/585 具体咨询 QQ 1405491181
  • 2017年02月16日 11:30

ARM_trustzone_security_whitepaper

  • 2011年07月01日 16:31
  • 685KB
  • 下载

HOJ 10027 Longest Ordered Subsequence Extention

Longest Ordered Subsequence Extention Time Limit: 1000ms, Special Time Limit:2500ms, Memory Lim...
  • u013595779
  • u013595779
  • 2014-04-16 17:14:38
  • 823

免费的ArcGIS Desktop Extension 【转】

 众所周知,ArcGIS Desktop有非常多的扩展选项,比如3D Analyst,Spatial Analyst,Schematics等等,但是肯定还是有非常多的人不知道ArcGIS实际上还提供了...
  • yuxi5622
  • yuxi5622
  • 2011-01-05 09:39:00
  • 1241

real time on windows

  • 2008年09月09日 16:36
  • 1018KB
  • 下载

( PHP console for chrome extention

  • 2014年11月25日 18:43
  • 54KB
  • 下载

Extension Point和学习

Contributing to Eclipse - Principles, Patterns, and Plug-ins 的第8章开头说,有人觉得设定Extension Point太难,其实并不如此。...
  • g9yuayon
  • g9yuayon
  • 2004-07-03 04:44:00
  • 2756

xpages客户端安装插件demo

designer客户端安装XPages Extension Library 其它就是下一步了!
  • weijia3624
  • weijia3624
  • 2015-04-13 19:54:02
  • 893

envi云检测和气溶胶检测插件

  • 2013年05月29日 22:38
  • 134KB
  • 下载

iOS学习笔记2(结合项目)--Category和Extension的区别

在实际项目中,用到Category比较多,Category也很实用,我们可以把一些经常用到或者很通用的功能封装到一个Category里,当其他项目需要相同的功能时,我们可以直接拿来用,不用从零开始写,...
  • jasonjwl
  • jasonjwl
  • 2015-11-02 17:04:18
  • 904
收藏助手
不良信息举报
您举报文章:The Program Extention
举报原因:
原因补充:

(最多只允许输入30个字)