From 188575e4d2135b8b5be6a234225a1b78fdfbe7c2 Mon Sep 17 00:00:00 2001 From: Saba Fazlali Date: Thu, 25 Jan 2024 11:35:20 +0100 Subject: [PATCH] word selector added --- src/main/c/Hangman/word_selector.c | 37 ++++++++++++++++++++++++++++++ src/main/c/Hangman/word_selector.h | 16 +++++++++++++ src/main/c/main.c | 4 ++-- 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 src/main/c/Hangman/word_selector.c create mode 100644 src/main/c/Hangman/word_selector.h diff --git a/src/main/c/Hangman/word_selector.c b/src/main/c/Hangman/word_selector.c new file mode 100644 index 0000000..0375253 --- /dev/null +++ b/src/main/c/Hangman/word_selector.c @@ -0,0 +1,37 @@ +// +// Created by Saba Fazlali on 22.01.24. +// + +#include "word_selector.h" + +const char wordsList[NUM_WORDS][MAX_WORD_LENGTH + 1] = { + "skill", + "world", + "difference", + "celebration", + "association", + "customer", + "mood", + "agreement", + "audience", + "professor", + "year", + "dealer", + "patience", + "initiative", + "pollution", + "awareness", + "problem", + "vehicle", + "death", + "cousin" +}; + +const char* selectRandomWord() { + + // pick a random number and assign it to index of wordsList array + srand((unsigned int)time(NULL)); + int randomIndex = rand() % NUM_WORDS; + + return wordsList[randomIndex]; +} \ No newline at end of file diff --git a/src/main/c/Hangman/word_selector.h b/src/main/c/Hangman/word_selector.h new file mode 100644 index 0000000..9d5dd39 --- /dev/null +++ b/src/main/c/Hangman/word_selector.h @@ -0,0 +1,16 @@ +// +// Created by Saba Fazlali on 24.01.24. +// + +#ifndef PMUW_PROJEKT_NOTEBINDER_WORD_SELECTOR_H +#define PMUW_PROJEKT_NOTEBINDER_WORD_SELECTOR_H + +#include +#include +#include +#include + +#define MAX_WORD_LENGTH 20 +#define NUM_WORDS 20 + +#endif //PMUW_PROJEKT_NOTEBINDER_WORD_SELECTOR_H diff --git a/src/main/c/main.c b/src/main/c/main.c index eaf0b17..90f28f1 100644 --- a/src/main/c/main.c +++ b/src/main/c/main.c @@ -2,7 +2,7 @@ #include #include -#include "Template/game100.h" +//#include "Template/game100.h" int main(){ bool running = true; @@ -37,7 +37,7 @@ int main(){ //start_game4(); break; case 100: - start_game100(); + //start_game100(); break; case 6: system("clear");