Fix Output

This commit is contained in:
Samuel Oberhofer 2022-06-24 16:37:09 +02:00
parent b4f36b5b7a
commit 8f7a0903be
2 changed files with 5 additions and 2 deletions

View File

@ -16,6 +16,7 @@ void Drone::returnChange(float change) {
}
while (restChange >= availableCashInstances[i].value &&
availableCashInstances[i].availableAmount > 0) {
std::cout << availableCashInstances[i].value << " " << std::flush;
#ifdef DEBUG
std::cout << "restChange: " << restChange
<< " Current Coin: " << availableCashInstances[i].value
@ -27,6 +28,7 @@ void Drone::returnChange(float change) {
100;
}
}
std::cout << std::endl;
if (restChange > 0.009) {
for (int i = CashInstanceSize - 1; i >= 0; i--) {
if (availableCashInstances[i].value >= restChange &&

View File

@ -2,10 +2,11 @@
int main() {
CashInstance wallet[8] = {CashInstance(0.01, 0), CashInstance(0.02, 0),
CashInstance(0.05, 0), CashInstance(0.1, 2),
CashInstance(0.05, 0), CashInstance(0.1, 3),
CashInstance(0.2, 0), CashInstance(0.5, 10),
CashInstance(1.0, 4), CashInstance(2, 4)};
Drone drone(wallet, 8);
drone.returnChange(drone.calculateChange(5, 20));
float change = drone.calculateChange(5.2, 20);
drone.returnChange(change);
return 0;
}