From 814c0eb148e9220511e9fa5f8e64b97fb7f3caf3 Mon Sep 17 00:00:00 2001 From: fdai7057 Date: Fri, 20 Jan 2023 10:42:35 +0100 Subject: [PATCH] implementation of collectCustomerProperties() --- src/CreateCustomer.c | 73 ++++++++++++++++++++++++++++++++++++++++ src/CreateCustomer.h | 2 ++ src/CustomerProperties.h | 7 ++++ 3 files changed, 82 insertions(+) create mode 100644 src/CustomerProperties.h diff --git a/src/CreateCustomer.c b/src/CreateCustomer.c index 26bf617..4d25a1e 100644 --- a/src/CreateCustomer.c +++ b/src/CreateCustomer.c @@ -1,6 +1,14 @@ #include "CreateCustomer.h" +#include "CustomerProperties.h" + +int main() +{ + collectCustomerProperties(); +} + int generateID() { + srand(time(0)); const int MIN = 1000000, MAX = 10000000; int p_val = rand() % (MAX); if(p_val=letterMaximum){ + inputTooLong = true; + break; + } + } + if(inputTooLong){ + printf("Forename too long. Aborting.\n"); + exit(-1); + }else{ + *(instance.forename+letterCounter) = '\0'; + letterCounter = 0; + } + printf("Enter surname (max. 15 letters):\n"); + while(letterCounter=letterMaximum){ + inputTooLong = true; + break; + } + } + if(inputTooLong){ + printf("Surname too long. Aborting.\n"); + exit(-1); + }else{ + *(instance.surname+letterCounter) = '\0'; + letterCounter = 0; + } + printf("Enter password (max. 20 letters):\n"); + while(letterCounter=letterMaximum){ + inputTooLong = true; + break; + } + } + if(inputTooLong){ + printf("Password too long. Aborting.\n"); + exit(-1); + } + *(instance.password+letterCounter) = '\0'; + letterCounter = 0; + printf("Enter balance:\n"); + scanf("%f",&instance.balance); + + printf("Account successfully created. Your ID is: %d. Note it somewhere!\n",instance.ID); +} diff --git a/src/CreateCustomer.h b/src/CreateCustomer.h index add2b60..cb425a1 100644 --- a/src/CreateCustomer.h +++ b/src/CreateCustomer.h @@ -1,4 +1,6 @@ #include #include +#include #include int generateID(); +void collectCustomerProperties(); diff --git a/src/CustomerProperties.h b/src/CustomerProperties.h new file mode 100644 index 0000000..0463c2d --- /dev/null +++ b/src/CustomerProperties.h @@ -0,0 +1,7 @@ +typedef struct Customer +{ + unsigned int ID; + char *password; + char *forename, *surname; + float balance; +}customer_t;