Browse Source

renaming files: source and header files start with lower case letters. Fixingorder of statements in build-project.sh

remotes/origin/beta
fdai7057 2 years ago
committed by fdai7207
parent
commit
b35e3262e9
  1. 2
      src/CustomerData.txt
  2. 2
      src/LoginCustomer.h
  3. 15
      src/createCustomer.c
  4. 2
      src/createCustomer.h
  5. 0
      src/customerProperties.h
  6. 6
      src/main.c
  7. 13
      src/mainMenu.c
  8. 2
      tests/test_CreateCustomer.c

2
src/CustomerData.txt

@ -4,3 +4,5 @@ forename=Max
Surname=Mustermann Surname=Mustermann
password=example password=example
balance=0 balance=0

2
src/LoginCustomer.h

@ -2,7 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include "CustomerProperties.h"
#include "customerProperties.h"
#define MAX_LOGIN_ATTEMPTS 3 #define MAX_LOGIN_ATTEMPTS 3
char *generateCheckString(char *, char*); char *generateCheckString(char *, char*);
bool checkLogin(bool); bool checkLogin(bool);

15
src/CreateCustomer.c → src/createCustomer.c

@ -1,13 +1,5 @@
#include "CreateCustomer.h"
#include "createCustomer.h"
/*Code written by Julius Philipp Engel, fdai7057*/ /*Code written by Julius Philipp Engel, fdai7057*/
/*
int main()
{
collectCustomerProperties();
}
*/
int generateID() int generateID()
{ {
srand(clock()); srand(clock());
@ -27,6 +19,7 @@ void collectCustomerProperties()
int letterMaximum = 15; int letterMaximum = 15;
char userInput=' '; char userInput=' ';
bool inputTooLong = false; bool inputTooLong = false;
fflush(stdin);
printf("To create a new user, enter the information required below.\n"); printf("To create a new user, enter the information required below.\n");
printf("Enter forename (max. 15 letters):\n"); printf("Enter forename (max. 15 letters):\n");
while(letterCounter<letterMaximum && (userInput=getchar())!='\n'){ while(letterCounter<letterMaximum && (userInput=getchar())!='\n'){
@ -61,10 +54,10 @@ void collectCustomerProperties()
letterCounter = 0; letterCounter = 0;
} }
printf("Enter password (max. 20 letters):\n"); printf("Enter password (max. 20 letters):\n");
while(letterCounter<letterMaximum && (userInput=getchar())!='\n'){
while(letterCounter<=(letterMaximum+5) && (userInput=getchar())!='\n'){
*(instance.password+letterCounter) = userInput; *(instance.password+letterCounter) = userInput;
++letterCounter; ++letterCounter;
if(letterCounter>=letterMaximum){
if(letterCounter>=letterMaximum+5){
inputTooLong = true; inputTooLong = true;
break; break;
} }

2
src/CreateCustomer.h → src/createCustomer.h

@ -2,7 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include <time.h> #include <time.h>
#include "CustomerProperties.h"
#include "customerProperties.h"
int generateID(); int generateID();
void collectCustomerProperties(); void collectCustomerProperties();
void writeCustomerPropertiesToFile(customer_t *); void writeCustomerPropertiesToFile(customer_t *);

0
src/CustomerProperties.h → src/customerProperties.h

6
src/main.c

@ -1,8 +1,6 @@
#include "mainMenu.h" #include "mainMenu.h"
int main() {
int main()
{
ageInput(); ageInput();
return 0;
} }

13
src/mainMenu.c

@ -1,4 +1,5 @@
#include"mainMenu.h" #include"mainMenu.h"
#include"createCustomer.c"
bool agePermission(int age) bool agePermission(int age)
@ -23,7 +24,7 @@ bool checkIfInteger(char* userInput)
void ageInput() void ageInput()
{ {
char* userInput = malloc(20*sizeof(char*));
char* userInput = malloc(20*sizeof(char));
char* userInputPointer; char* userInputPointer;
long age; long age;
@ -31,6 +32,8 @@ void ageInput()
printf("\nPlease specify your age : "); printf("\nPlease specify your age : ");
scanf("%s",userInput); scanf("%s",userInput);
int c;
while ((c = getchar()) != '\n' && c != EOF) {};
while (true) while (true)
{ {
@ -38,10 +41,10 @@ void ageInput()
if((checkIfInteger(userInput))&& (agePermission(age))) if((checkIfInteger(userInput))&& (agePermission(age)))
{ {
//age = strtol(userInput,&userInputPointer,10);
printf("Access granted!\n\n\n\n");
age = strtol(userInput,&userInputPointer,10);
//printf("Access granted!\n\n\n\n");
collectCustomerProperties();
showMenu(); showMenu();
break; break;
@ -61,7 +64,9 @@ void ageInput()
{ {
printf("input invalid! try again!\n"); printf("input invalid! try again!\n");
fflush(stdin);
scanf("%s",userInput); scanf("%s",userInput);
fflush(stdin);
} }

2
tests/test_CreateCustomer.c

@ -1,6 +1,6 @@
#include <unity.h> #include <unity.h>
#include <limits.h> #include <limits.h>
#include "CreateCustomer.h"
#include "createCustomer.h"
void setUp(){} void setUp(){}
void tearDown(){} void tearDown(){}

Loading…
Cancel
Save