我被要求(至少对我来说具有挑战性)在应用程序中编写逻辑。我必须编写一个业务逻辑,其中它应该执行以下功能
Total current consumption = current from A elements + current from B elements.
A and B are different types of devices
现在假设提供电流(A+B) 所需的电池为“X”
每个 X 也可以贡献总电流消耗,因此我需要再次计算总电流消耗,就像第一步一样,包括电池电流消耗
IE
`Total current consumed : A + B + X"`
where X" is the current consumption of the battery
现在我应该再次计算所需的电池。让我们把它说成 Y
IE
要供应 A + B + X”,我们需要 Y 块电池。
Now check whether X == Y ?
If same, then return Y and exit
else add more X to the sum (A + B + X") till X == Y
任何人都可以帮助我使用初始伪代码集吗?任何形式的建议也很感激
Yes the end result this logic should return is number of batteries required. However it should return this result only after computing the total current consumption recursively till X == Y, where
A : total current consumption of some active elements in a system.
B : total current consumption of some passive elements in a system
Total current consumption is A + B
to supply current of (A+B) amperes i require 'X' no. of batteries.
However each battery also adds some delta amount of current to the total value i.e
A + B + X"
if the batteries required to supply this delta is still 'X', then return X as the end result, else add more batteries --> calculate current --> no of batteries required ---> check again and so on ...