Ik heb gekregen een vereiste (een uitdaging voor mij althans) om een logica in een toepassing te schrijven. Ik heb een business logica te schrijven, waarin hij de volgende functionaliteit moet uitvoeren
Total current consumption = current from A elements + current from B elements.
A and B are different types of devices
Laten we nu zeggen dat het nodig is om de stroom leveren batterijen (A + B) zijn 'X'
Ook elke X kan bijdragen aan het totale stroomverbruik, dus ik nodig om het totale stroomverbruik opnieuw berekenen net als de eerste stap inclusief de batterij stroomverbruik
d.w.z
`Total current consumed : A + B + X`
where X is the current consumption of the battery
Nu weer moet ik de benodigde batterijen te berekenen. Laten we zeggen als Y
d.w.z
om het aanbod A + B + X we moeten Y aantal batterijen.
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
Kan iemand me helpen met de eerste reeks van pseudocode? Elke vorm van suggestie wordt ook gewaardeerd
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 ...













