Adding assignment 1
This commit is contained in:
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
8
assignment1/.idea/.gitignore
generated
vendored
Normal file
8
assignment1/.idea/.gitignore
generated
vendored
Normal file
@@ -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
|
||||
2
assignment1/.idea/IKT203.iml
generated
Normal file
2
assignment1/.idea/IKT203.iml
generated
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
||||
7
assignment1/.idea/misc.xml
generated
Normal file
7
assignment1/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CMakePythonSetting">
|
||||
<option name="pythonIntegrationState" value="YES" />
|
||||
</component>
|
||||
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||
</project>
|
||||
8
assignment1/.idea/modules.xml
generated
Normal file
8
assignment1/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/IKT203.iml" filepath="$PROJECT_DIR$/.idea/IKT203.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
12
assignment1/CMakeLists.txt
Normal file
12
assignment1/CMakeLists.txt
Normal file
@@ -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)
|
||||
5
assignment1/TMovie.cpp
Normal file
5
assignment1/TMovie.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Created by csand on 13/10/2025.
|
||||
//
|
||||
|
||||
#include "TMovie.h"
|
||||
66
assignment1/TMovie.h
Normal file
66
assignment1/TMovie.h
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
|
||||
#ifndef IKT203_TMOVIE_H
|
||||
#define IKT203_TMOVIE_H
|
||||
|
||||
|
||||
#include <wsman.h>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
// 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
|
||||
5
assignment1/TMovieList.cpp
Normal file
5
assignment1/TMovieList.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Created by csand on 13/10/2025.
|
||||
//
|
||||
|
||||
#include "TMovieList.h"
|
||||
33
assignment1/TMovieList.h
Normal file
33
assignment1/TMovieList.h
Normal file
@@ -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
|
||||
6
assignment1/TMovieNode.cpp
Normal file
6
assignment1/TMovieNode.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
//
|
||||
// Created by csand on 13/10/2025.
|
||||
//
|
||||
|
||||
#include "TMovieNode.h"
|
||||
|
||||
45
assignment1/TMovieNode.h
Normal file
45
assignment1/TMovieNode.h
Normal file
@@ -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
|
||||
11
assignment1/main.cpp
Normal file
11
assignment1/main.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <iostream>
|
||||
#include <wsman.h>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user