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. 4
      build-project.sh
  2. 2
      src/CustomerData.txt
  3. 2
      src/LoginCustomer.h
  4. 15
      src/createCustomer.c
  5. 2
      src/createCustomer.h
  6. 0
      src/customerProperties.h
  7. 8
      src/main.c
  8. 13
      src/mainMenu.c
  9. 2
      tests/test_CreateCustomer.c

4
build-project.sh

@ -1,6 +1,6 @@
clear
ceedling test:all
cd src/
gcc main.c mainMenu.c -o main
gcc main.c mainMenu.c -o main
./main
rm main
rm main

2
src/CustomerData.txt

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

2
src/LoginCustomer.h

@ -2,7 +2,7 @@
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include "CustomerProperties.h"
#include "customerProperties.h"
#define MAX_LOGIN_ATTEMPTS 3
char *generateCheckString(char *, char*);
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*/
/*
int main()
{
collectCustomerProperties();
}
*/
int generateID()
{
srand(clock());
@ -27,6 +19,7 @@ void collectCustomerProperties()
int letterMaximum = 15;
char userInput=' ';
bool inputTooLong = false;
fflush(stdin);
printf("To create a new user, enter the information required below.\n");
printf("Enter forename (max. 15 letters):\n");
while(letterCounter<letterMaximum && (userInput=getchar())!='\n'){
@ -61,10 +54,10 @@ void collectCustomerProperties()
letterCounter = 0;
}
printf("Enter password (max. 20 letters):\n");
while(letterCounter<letterMaximum && (userInput=getchar())!='\n'){
while(letterCounter<=(letterMaximum+5) && (userInput=getchar())!='\n'){
*(instance.password+letterCounter) = userInput;
++letterCounter;
if(letterCounter>=letterMaximum){
if(letterCounter>=letterMaximum+5){
inputTooLong = true;
break;
}

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

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

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

8
src/main.c

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

13
src/mainMenu.c

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

2
tests/test_CreateCustomer.c

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

Loading…
Cancel
Save