Diff: Bankomat.cpp
- Revision:
- 0:465c627254e2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Bankomat.cpp Fri Jun 22 13:56:38 2018 +0000 @@ -0,0 +1,56 @@ +#include "mbed.h" +#include "Bankomat.h" + + + void Bankomat::random() + { + for(int i=0;i<4;i++) + { + Pincode =rand() % 9+1; + Pincheck[i]=Pincode+48; + // printf("\npincode: %i\n", Pincode); + //printf("\npincheck: %i\n", Pincheck[i]); + Zahl[i] = Pincode; + //printf("\nZahl: %i\n", Zahl[i]); + clearleds(); + wait_ms(1500); + showPin(); + + // printf("P %i_",Pincode); + // printf("C %c\t",Pincheck[i]); + } + printf("\n_\t_\t_\t_\t\n\n"); + } + + void Bankomat::showPin() + { + _allleds=Pincode; + + wait_ms(1500); + clearleds(); + } + + void Bankomat::eingabe() + { + scanf("%i",&Pinzahl[0]); + scanf("%i",&Pinzahl[1]); + scanf("%i",&Pinzahl[2]); + scanf("%i",&Pinzahl[3]); + } + +void Bankomat::ausgabe() +{ + printf("\nEingegeben: \n%i\t%i\t%i\t%i\t\n\n",Pinzahl[0],Pinzahl[1],Pinzahl[2],Pinzahl[3]); + printf("\nPIN: \n%i\t%i\t%i\t%i\t\n\n",Zahl[0],Zahl[1],Zahl[2],Zahl[3]); + if(Pinzahl[0] != Zahl[0]||Pinzahl[1] != Zahl[1]||Pinzahl[2] != Zahl[2]||Pinzahl[3] != Zahl[3]) + printf("\nPIN falsch!\n"); + else + printf("\nPIN richtig! Trotzdem gibt's kein Geld!!!\n"); +} + +void Bankomat::clearleds() +{ _led1=0; + _led2=0; + _led3=0; + _led4=0; +}