2024-12-09 19:27:50 +01:00
|
|
|
/*
|
|
|
|
* command line interface for user input
|
|
|
|
*
|
|
|
|
*/
|
2024-12-14 10:01:08 +01:00
|
|
|
/* Created by Juergen Buechel, 13.12.2024/
|
2024-12-14 22:40:29 +01:00
|
|
|
*/
|
|
|
|
#include "ui.h"
|
|
|
|
// #include "db.h"
|
|
|
|
#include "llist.h"
|
2024-12-14 21:36:09 +01:00
|
|
|
#include "planner.h" // for subject and event structs
|
2024-12-14 22:40:29 +01:00
|
|
|
#include <assert.h>
|
2024-12-13 22:26:20 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2024-12-14 22:14:17 +01:00
|
|
|
|
2024-12-14 22:40:29 +01:00
|
|
|
int main(void) {
|
|
|
|
char taskname[256]; // taskName Buffer
|
|
|
|
int taskcreation_date = 0;
|
|
|
|
int taskdeadline_date = 0;
|
|
|
|
int taskpriority = 0;
|
|
|
|
int taskspare = 0;
|
|
|
|
// llist *list = NULL;
|
|
|
|
//
|
|
|
|
// Task *task = newTask(taskname, taskcreation_date, taskdeadline_date,
|
|
|
|
// taskpriority, taskspare); if (task == NULL) {
|
|
|
|
// printf("Fehler beim Erstellen der Aufgabe.\n");
|
|
|
|
// return 0;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (list == NULL) {
|
|
|
|
// list = llistNew(task, cmpTaskN);
|
|
|
|
// } else {
|
|
|
|
// list = llistAppend(list, task); // Rückgabewert verwenden
|
|
|
|
// }
|
|
|
|
llist *list = llistNew(NULL, cmpTaskN);
|
|
|
|
if (list == NULL) {
|
|
|
|
printf("Fehler beim Erstellen der Aufgabe.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2024-12-14 22:14:17 +01:00
|
|
|
|
2024-12-14 22:44:45 +01:00
|
|
|
<<<<<<< HEAD
|
2024-12-14 22:40:29 +01:00
|
|
|
int choice = 0, i = 0;
|
|
|
|
do {
|
|
|
|
printf(" -1- Neues Fach eingeben\n");
|
|
|
|
printf(" -2- Verfuegbare Zeit eingeben\n");
|
|
|
|
printf(" -3- Alle vorhandenen Faecher aufliesten\n");
|
|
|
|
printf(" -4- Kalenderlink ausgeben\n");
|
|
|
|
printf(" -5- Planer beenden\n");
|
|
|
|
printf(" Wähle die gewünschte Option aus\n");
|
|
|
|
if (scanf("%d", &choice) != 1) {
|
|
|
|
printf("Falsche Eingabe\n");
|
|
|
|
};
|
|
|
|
choice = 0;
|
2024-12-14 22:14:17 +01:00
|
|
|
|
2024-12-14 22:40:29 +01:00
|
|
|
while ((choice < 1 || choice > 5)) {
|
|
|
|
switch (choice) {
|
|
|
|
case 1: {
|
|
|
|
printf(" Geben sie das gewünschte Fach ein: \n");
|
|
|
|
if (scanf("%255s", taskname) != 1) {
|
|
|
|
printf("Ungültige Eingabe für den Namen.\n");
|
|
|
|
return -1;
|
2024-12-14 22:44:45 +01:00
|
|
|
=======
|
2024-12-14 22:14:17 +01:00
|
|
|
int main(void)
|
|
|
|
{
|
2024-12-14 22:37:18 +01:00
|
|
|
char *taskname = "empty";
|
2024-12-14 22:14:56 +01:00
|
|
|
int taskcreation_date = 0;
|
2024-12-14 22:14:17 +01:00
|
|
|
int taskdeadline_date = 0;
|
2024-12-14 22:14:56 +01:00
|
|
|
int taskpriority = 0;
|
|
|
|
int taskspare = 0;
|
2024-12-14 22:14:17 +01:00
|
|
|
llist *list = NULL;
|
|
|
|
|
|
|
|
Task *task = newTask(taskname, taskcreation_date, taskdeadline_date, taskpriority, taskspare);
|
|
|
|
if (task == NULL) {
|
|
|
|
printf("Fehler beim Erstellen der Aufgabe.\n");
|
2024-12-14 22:20:10 +01:00
|
|
|
return 0;
|
2024-12-14 21:44:35 +01:00
|
|
|
}
|
2024-12-14 22:14:17 +01:00
|
|
|
|
|
|
|
if (list == NULL) {
|
|
|
|
list = llistNew(task, cmpTaskN);
|
|
|
|
} else {
|
|
|
|
list = llistAppend(list, task); // Rückgabewert verwenden
|
2024-12-13 22:26:20 +01:00
|
|
|
}
|
2024-12-14 22:14:17 +01:00
|
|
|
|
|
|
|
int choice = 0, i = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
printf(" -1- Neues Fach eingeben\n");
|
|
|
|
printf(" -2- Verfuegbare Zeit eingeben\n");
|
|
|
|
printf(" -3- Alle vorhandenen Faecher aufliesten\n");
|
|
|
|
printf(" -4- Kalenderlink ausgeben\n");
|
|
|
|
printf(" -5- Planer beenden\n");
|
|
|
|
printf(" Wähle die gewünschte Option aus\n");
|
|
|
|
if( scanf("%d", &choice) != 1){
|
|
|
|
printf("Falsche Eingabe\n");};
|
|
|
|
choice = 0;
|
|
|
|
|
2024-12-14 22:26:40 +01:00
|
|
|
while(( choice < 1 || choice > 5)){
|
|
|
|
switch (choice){
|
|
|
|
case 1:{
|
2024-12-14 22:14:17 +01:00
|
|
|
printf(" Geben sie das gewünschte Fach ein: \n");
|
2024-12-14 22:37:18 +01:00
|
|
|
if (scanf("%c", taskname) != 1) {
|
2024-12-14 22:14:17 +01:00
|
|
|
printf("Ungültige Eingabe für den Namen.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
printf(" Wie viel Zeit bleibt ihnen:\n");
|
|
|
|
if (scanf("%d", &taskdeadline_date) != 1) {
|
|
|
|
printf("Ungültige Eingabe.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
printf(" Gib die Priorität des Faches an: \n");
|
|
|
|
if (scanf("%d", &taskpriority) != 1) {
|
|
|
|
printf("Ungültige Eingabe.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
printf(" Wie viel Zeit habe Sie für dieses Fach: \n");
|
|
|
|
if (scanf("%d", &taskspare) != 1) {
|
|
|
|
printf("Ungültige Eingabe.\n");
|
|
|
|
return -1;
|
2024-12-14 22:20:10 +01:00
|
|
|
}
|
2024-12-14 22:14:17 +01:00
|
|
|
break;
|
2024-12-14 22:20:10 +01:00
|
|
|
case 2:
|
|
|
|
printf("Geben Sie die zur verfuegung stehende Zeit für die Fächer an: \n");
|
|
|
|
scanf("%c", &taskspare);
|
2024-12-14 22:14:17 +01:00
|
|
|
break;
|
|
|
|
|
2024-12-14 22:26:40 +01:00
|
|
|
case 3: if( task == NULL){
|
2024-12-14 22:20:10 +01:00
|
|
|
printf("Die Liste ist leer");
|
|
|
|
}
|
2024-12-14 22:26:40 +01:00
|
|
|
else{
|
2024-12-14 22:20:10 +01:00
|
|
|
llist *iterator = list;
|
|
|
|
while (iterator != NULL) {
|
|
|
|
Task *currentTask = (Task *)(iterator->data); // Cast zu Task
|
|
|
|
printf("Fach: %s, Deadline: %ld, Priorität: %d\n",
|
|
|
|
currentTask->name, currentTask->deadline, currentTask->priority);
|
|
|
|
iterator = iterator->next; // Gehe zum nächsten Listenelement
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
// case 4: iCAl();break;
|
|
|
|
}
|
2024-12-14 22:14:17 +01:00
|
|
|
}
|
2024-12-14 22:44:45 +01:00
|
|
|
>>>>>>> cf63dc47121e0381e7850dcf85ad23b4c82dd268
|
2024-12-14 22:40:29 +01:00
|
|
|
}
|
2024-12-14 22:14:17 +01:00
|
|
|
|
2024-12-14 22:40:29 +01:00
|
|
|
printf(" Wie viel Zeit bleibt ihnen:\n");
|
|
|
|
if (scanf("%d", &taskdeadline_date) != 1) {
|
|
|
|
printf("Ungültige Eingabe.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2024-12-14 22:14:17 +01:00
|
|
|
|
2024-12-14 22:40:29 +01:00
|
|
|
printf(" Gib die Priorität des Faches an: \n");
|
|
|
|
if (scanf("%d", &taskpriority) != 1) {
|
|
|
|
printf("Ungültige Eingabe.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2024-12-14 22:14:17 +01:00
|
|
|
|
2024-12-14 22:40:29 +01:00
|
|
|
printf(" Wie viel Zeit habe Sie für dieses Fach: \n");
|
|
|
|
if (scanf("%d", &taskspare) != 1) {
|
|
|
|
printf("Ungültige Eingabe.\n");
|
|
|
|
return -1;
|
2024-12-14 22:20:10 +01:00
|
|
|
}
|
2024-12-14 22:40:29 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
printf(
|
|
|
|
"Geben Sie die zur verfuegung stehende Zeit für die Fächer an: \n");
|
|
|
|
scanf("%d", &taskspare);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
// if (task == NULL) {//task?
|
|
|
|
// printf("Die Liste ist leer");
|
|
|
|
// } else {
|
|
|
|
// llist *iterator = list;
|
|
|
|
// while (iterator != NULL) {
|
|
|
|
// Task *currentTask = (Task *)(iterator->data); // Cast zu Task
|
|
|
|
// printf("Fach: %s, Deadline: %ld, Priorität: %d\n",
|
|
|
|
// currentTask->name, currentTask->deadline,
|
|
|
|
// currentTask->priority);
|
|
|
|
// iterator = iterator->next; // Gehe zum nächsten Listenelement
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
break;
|
|
|
|
// case 4: iCAl();break;
|
|
|
|
}
|
|
|
|
}
|
2024-12-14 22:20:10 +01:00
|
|
|
}
|
2024-12-14 22:40:29 +01:00
|
|
|
} while (choice != 5);
|
|
|
|
{
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|