Home  >  Q&A  >  body text

c++ - 用友笔试题类设计

用友今天的笔试题,设计类
根据下面的描述画出实现该功能的类图
目前海关针对书籍 食品 药品的税收如下:
基本销售税率为10%,除食品外都要征收
进口附加税5%,所有进口商品都要征收没有例外。

提示:要考虑征收的税种会增加,税率会变化以及征收商品种类的变化。

我对设计模式之类的一无所知,不知道这个题会不会用到设计模式的知识,我再考场上完全不知道如何作答。

大家讲道理大家讲道理2715 days ago660

reply all(1)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-17 13:04:15

    That is to say. 1. Each product has a category. 2. The tax rate only depends on the classification, remains unchanged for a certain period of time, and may be modified manually.

    The corresponding countermeasure is to use the bridge mode between categories and products, that is, the category is a field of the product and is not directly derived from the product base class.

    After that, the tax rate calculator object is obtained using the abstract factory mode, and the corresponding object is obtained according to the type. Calculator objects are directly implemented by an interface. After the tax rate changes, just change the corresponding objects.

    reply
    0
  • Cancelreply