如何简化这个long if else语句? [英] How to simplify this long if else statement?

查看:72
本文介绍了如何简化这个long if else语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个产品。所有产品都有相同的价格,我给它命名:价格


每个产品都有折扣。我将其变量定义如下:

discount1,discount2,discount3


但是当折扣等于100%时,每种产品都有不同的税(例如)如下:

tax1,tax2,tax3


我写了这段代码,效果很好:

I have 3 products. All the products have the same price, I named it : price

Each product has a discount. I defined its variables as follows:
discount1, discount2, discount3

But there is a different tax for each product when the discount equals 100% (for example) as follows:
tax1, tax2, tax3

I wrote this code and it works well:

展开 | 选择 | Wrap | 行号

推荐答案

展开 | 选择 | Wrap | 行号


展开 | 选择 | Wrap | 行号


@Jhardman:问题是3条件可能发生在同时
@Jhardman: The problem is that the 3 condition can happen at the same time


这篇关于如何简化这个long if else语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆