commit 7a8b356e96cd91f581426ded29eb0ddd81574e78 Author: Christopher Sanden Date: Mon Oct 13 17:19:15 2025 +0200 Adding assignment 1 diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/assignment1/.idea/.gitignore b/assignment1/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/assignment1/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/assignment1/.idea/IKT203.iml b/assignment1/.idea/IKT203.iml new file mode 100644 index 0000000..f08604b --- /dev/null +++ b/assignment1/.idea/IKT203.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assignment1/.idea/misc.xml b/assignment1/.idea/misc.xml new file mode 100644 index 0000000..0b76fe5 --- /dev/null +++ b/assignment1/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/assignment1/.idea/modules.xml b/assignment1/.idea/modules.xml new file mode 100644 index 0000000..0e7fea3 --- /dev/null +++ b/assignment1/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/assignment1/CMakeLists.txt b/assignment1/CMakeLists.txt new file mode 100644 index 0000000..e7cb06d --- /dev/null +++ b/assignment1/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.31) +project(IKT203) + +set(CMAKE_CXX_STANDARD 20) + +add_executable(IKT203 main.cpp + TMovie.cpp + TMovie.h + TMovieNode.cpp + TMovieNode.h + TMovieList.cpp + TMovieList.h) diff --git a/assignment1/TMovie.cpp b/assignment1/TMovie.cpp new file mode 100644 index 0000000..a92d8dc --- /dev/null +++ b/assignment1/TMovie.cpp @@ -0,0 +1,5 @@ +// +// Created by csand on 13/10/2025. +// + +#include "TMovie.h" diff --git a/assignment1/TMovie.h b/assignment1/TMovie.h new file mode 100644 index 0000000..cf65bf0 --- /dev/null +++ b/assignment1/TMovie.h @@ -0,0 +1,66 @@ + + +#ifndef IKT203_TMOVIE_H +#define IKT203_TMOVIE_H + + +#include +#include +#include + +// I know there's debate on the use of namespace, but honestly +// I cba to write std:: before everything... +using namespace std; + +enum EMovieGenreType{ + ACTION = 1 << 0, + COMEDY = 1<< 1, + SCIFI = 1 << 2, + HORROR = 1 << 3, + DRAMA = 1 << 4 +}; + + +class TMovie + { + private: + string title; + string director; + int year; + EMovieGenreType genre; + float score; + + public: + + TMovie(string T, 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]] string GetTitle() const + { + return title; + } + [[nodiscard]] 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/TMovieList.cpp b/assignment1/TMovieList.cpp new file mode 100644 index 0000000..e750258 --- /dev/null +++ b/assignment1/TMovieList.cpp @@ -0,0 +1,5 @@ +// +// Created by csand on 13/10/2025. +// + +#include "TMovieList.h" diff --git a/assignment1/TMovieList.h b/assignment1/TMovieList.h new file mode 100644 index 0000000..d26a153 --- /dev/null +++ b/assignment1/TMovieList.h @@ -0,0 +1,33 @@ +#ifndef IKT203_TMOVIELIST_H +#define IKT203_TMOVIELIST_H + +#include "TMovie.h" +#include "TMovieNode.h" + + + +using namespace std; + +class TMovieList { +private: + TMovieNode* head; + +public: + TMovieList() : head(new TMovieNode(nullptr)) {} + + ~TMovieList() + { + TMovieNode* current = head; + while(current) + { + TMovieNode* next = current->GetNextNode(); + delete current; + current = next; + } + head = nullptr; + } + +}; + + +#endif //IKT203_TMOVIELIST_H diff --git a/assignment1/TMovieNode.cpp b/assignment1/TMovieNode.cpp new file mode 100644 index 0000000..c63315d --- /dev/null +++ b/assignment1/TMovieNode.cpp @@ -0,0 +1,6 @@ +// +// Created by csand on 13/10/2025. +// + +#include "TMovieNode.h" + diff --git a/assignment1/TMovieNode.h b/assignment1/TMovieNode.h new file mode 100644 index 0000000..9a37205 --- /dev/null +++ b/assignment1/TMovieNode.h @@ -0,0 +1,45 @@ +#ifndef IKT203_TMOVIENODE_H +#define IKT203_TMOVIENODE_H + +#include "TMovie.h" + + + +using namespace std; + + + +class TMovieNode { +private: + + TMovie* movie; + TMovieNode* nextNode; + +public: + + // constructor + explicit TMovieNode(TMovie* moviePointer) : movie(moviePointer), nextNode(nullptr) {} + + // destructor + ~TMovieNode() + { + delete movie; + movie = nullptr; + } + + // getter and setter for nextNode pointer + TMovieNode* GetNextNode() + { + return nextNode; + } + + void SetNextNode(TMovieNode* next) + { + nextNode = next; + } + +}; + + + +#endif //IKT203_TMOVIENODE_H diff --git a/assignment1/main.cpp b/assignment1/main.cpp new file mode 100644 index 0000000..c1f5624 --- /dev/null +++ b/assignment1/main.cpp @@ -0,0 +1,11 @@ +#include +#include + + +int main() +{ + + + + return 0; +} \ No newline at end of file