Μου δόθηκε μια απαίτηση (πρόκληση για μένα τουλάχιστον) να γράψει μια λογική σε μια εφαρμογή. Έχω να γράψω μια επιχειρηματική λογική στην οποία θα πρέπει να εκτελέσει τις ακόλουθες λειτουργίες
Total current consumption = current from A elements + current from B elements.
A and B are different types of devices
Τώρα ας πούμε οι μπαταρίες που απαιτούνται για τον εφοδιασμό της τρέχουσας (Α + Β) να είναι «X»
Επίσης κάθε Χ μπορεί να συμβάλει στη συνολική κατανάλωση ρεύματος, ως εκ τούτου, εγώ πρέπει να υπολογίσει εκ νέου τη συνολική κατανάλωση ρεύματος ακριβώς όπως το πρώτο βήμα συμπεριλαμβανομένης της μπαταρίας κατανάλωση ρεύματος
δηλαδή
`Total current consumed : A + B + X`
where X is the current consumption of the battery
Τώρα και πάλι εγώ θα πρέπει να υπολογίσει τις μπαταρίες που απαιτούνται. Ας πούμε αυτό ως Υ
δηλαδή
να εφοδιασμού Α + Β + X»χρειαζόμαστε αριθμός Υ των μπαταριών.
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 ...













