diff --git a/.gitignore b/.gitignore index 55432e4..ed3fb7a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ *.zip *.ZIP *.Zip +*.clang-format +*cmake-build-debug +*.idea diff --git a/assignment1/DeliveryAssignment1/CMakeLists.txt b/assignment1/DeliveryAssignment1/CMakeLists.txt deleted file mode 100644 index 90ee4f4..0000000 --- a/assignment1/DeliveryAssignment1/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required(VERSION 4.0) -project(assignment1) - -set(CMAKE_CXX_STANDARD 20) - -add_executable(assignment1 main.cpp - TMovie.h - TMovie.cpp - TMovieList.cpp - TMovieList.h - TMovieNode.cpp - TMovieNode.h) diff --git a/assignment1/DeliveryAssignment1/TMovie.cpp b/assignment1/DeliveryAssignment1/TMovie.cpp deleted file mode 100644 index a92d8dc..0000000 --- a/assignment1/DeliveryAssignment1/TMovie.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// -// Created by csand on 13/10/2025. -// - -#include "TMovie.h" diff --git a/assignment1/DeliveryAssignment1/TMovie.h b/assignment1/DeliveryAssignment1/TMovie.h deleted file mode 100644 index c830548..0000000 --- a/assignment1/DeliveryAssignment1/TMovie.h +++ /dev/null @@ -1,59 +0,0 @@ - - -#ifndef IKT203_TMOVIE_H -#define IKT203_TMOVIE_H -#include -#include - -enum EMovieGenreType{ - ACTION = 1 << 0, - COMEDY = 1<< 1, - SCIFI = 1 << 2, - HORROR = 1 << 3, - DRAMA = 1 << 4 -}; - - -class TMovie - { - private: - std::string title; - std::string director; - int year; - EMovieGenreType genre; - float score; - - public: - - TMovie(std::string T, std::string D, int Y, EMovieGenreType G, float S) : - title(std::move(T)), director(std::move(D)), year(Y), genre(G), score(S) {} - - // Simple getters - using [[nodiscard]] to give warning if value is not used - [[nodiscard]] std::string GetTitle() const - { - return title; - } - [[nodiscard]] std::string GetDirector() const - { - return director; - } - [[nodiscard]] int GetYear() const - { - return year; - } - [[nodiscard]] EMovieGenreType GetGenre() const - { - return genre; - } - [[nodiscard]] float GetScore() const - { - return score; - } - - // Not declaring a destructor since the default compiler destructor is - - -}; - - -#endif //IKT203_TMOVIE_H diff --git a/assignment1/DeliveryAssignment1/TMovieList.cpp b/assignment1/DeliveryAssignment1/TMovieList.cpp deleted file mode 100644 index 4336c57..0000000 --- a/assignment1/DeliveryAssignment1/TMovieList.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include "TMovieList.h" - -#include - -using namespace std; - -void TMovieList::Append(TMovie* m) -{ - // Time complexity O(1) with using tail and prev nodes - auto* newNode = new TMovieNode(m); - newNode->SetPrevNode(tail); - tail->SetNextNode(newNode); - tail = newNode; - cout << "Appended '" << m->GetTitle() << "' into existing list of movies" <GetNextNode(); - newNode->SetNextNode(head->GetNextNode()); - head->SetNextNode(newNode); - - newNode->SetPrevNode(head); - if (old) - old->SetPrevNode(newNode); - - cout << "Prepended '" << m->GetTitle() << "' into list of movies" < ugyldig - if (index < 0) - return nullptr; - - auto* node = head->GetNextNode(); - int i = 0; - while (node != nullptr && i < index) - { - node = node->GetNextNode(); - i++; - } - - // Index større enn lista -> ugyldig - if (node == nullptr) - return nullptr; - return node; - -} - -TMovie* TMovieList::GetAtIndex(const int index) const -{ - auto* node = NavigateToNode(index); - return node ? node->GetMovie() : nullptr; -} - -void TMovieList::Remove(const int index) -{ - auto* node = NavigateToNode(index); - if (node == nullptr) - return; - - auto* prev = node->GetPrevNode(); - auto* next = node->GetNextNode(); - - if (prev) - prev->SetNextNode(next); - if (next) - next->SetPrevNode(prev); - else - tail = (prev ? prev : head); - - - if (head->GetNextNode() == nullptr) - tail = head; - - delete node; -} - -TMovie *TMovieList::SearchFor(const FCheckMovie check_movie, void *criteria) const -{ - auto* node = head->GetNextNode(); - while (node != nullptr) - { - if (check_movie(node->GetMovie(), criteria)) - { - return node->GetMovie(); - } - node = node->GetNextNode(); - } - return nullptr; -} diff --git a/assignment1/DeliveryAssignment1/TMovieList.h b/assignment1/DeliveryAssignment1/TMovieList.h deleted file mode 100644 index 6d9e02a..0000000 --- a/assignment1/DeliveryAssignment1/TMovieList.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef IKT203_TMOVIELIST_H -#define IKT203_TMOVIELIST_H - -#include "TMovie.h" -#include "TMovieNode.h" - -// typedef to increase flexibility and reduce code recycling -typedef bool (*FCheckMovie)(TMovie* movie, void* criteria); - -class TMovieList { -private: - TMovieNode* head; - TMovieNode* tail; - -public: - TMovieList() : head(new TMovieNode(nullptr)), tail(head) {} - - ~TMovieList() - { - TMovieNode* current = head; - while(current) - { - TMovieNode* next = current->GetNextNode(); - delete current; - current = next; - } - head = nullptr; - tail = nullptr; - } - void Append(TMovie* m); - void Prepend(TMovie* m); - TMovie* SearchFor(FCheckMovie check_movie, void* criteria) const; - - [[nodiscard]] TMovieNode *NavigateToNode(int index) const; - - [[nodiscard]] TMovie* GetAtIndex(int index) const; - void Remove(int index); -}; - - -#endif //IKT203_TMOVIELIST_H diff --git a/assignment1/DeliveryAssignment1/TMovieNode.cpp b/assignment1/DeliveryAssignment1/TMovieNode.cpp deleted file mode 100644 index c63315d..0000000 --- a/assignment1/DeliveryAssignment1/TMovieNode.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// Created by csand on 13/10/2025. -// - -#include "TMovieNode.h" - diff --git a/assignment1/DeliveryAssignment1/TMovieNode.h b/assignment1/DeliveryAssignment1/TMovieNode.h deleted file mode 100644 index 13cc3c7..0000000 --- a/assignment1/DeliveryAssignment1/TMovieNode.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef IKT203_TMOVIENODE_H -#define IKT203_TMOVIENODE_H - -#include "TMovie.h" - -class TMovieNode { -private: - - TMovie* movie; - TMovieNode* nextNode; - TMovieNode* prevNode; - -public: - - // constructor - explicit TMovieNode(TMovie* moviePointer) : movie(moviePointer), nextNode(nullptr), prevNode(nullptr) {} - - // destructor - ~TMovieNode() - { - delete movie; - movie = nullptr; - } - - // getters and setters for next and previous nodes - [[nodiscard]] TMovieNode* GetNextNode() const - { - return nextNode; - } - - void SetNextNode(TMovieNode* next) - { - nextNode = next; - } - - [[nodiscard]] TMovieNode* GetPrevNode() const - { - return prevNode; - } - void SetPrevNode(TMovieNode* prev) - { - prevNode = prev; - } - [[nodiscard]] TMovie* GetMovie() const - { - return movie; - } -}; - - - -#endif //IKT203_TMOVIENODE_H diff --git a/assignment1/DeliveryAssignment1/main.cpp b/assignment1/DeliveryAssignment1/main.cpp deleted file mode 100644 index de37b87..0000000 --- a/assignment1/DeliveryAssignment1/main.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include "TMovieList.h" - -// specialised versions of SearchFor() from TMovieList -bool SearchByTitle(const TMovie* m, void* c) -{ - const auto* title = static_cast(c); - return m->GetTitle() == *title; -} - -bool SearchByDirector(const TMovie* m, void* criteria) -{ - const auto* director = static_cast(criteria); - return m->GetDirector() == *director; -} - -bool SearchByGenre(const TMovie* m, void* criteria) -{ - const auto* genre = static_cast(criteria); - return m->GetGenre() == *genre; -} - - - - - -int main() -{ - - - -}