updated filestructure and gitignore. uploading exam progress
This commit is contained in:
40
Exam/IKT203Exam/Portfolio/Assignment-02/CMakeLists.txt
Normal file
40
Exam/IKT203Exam/Portfolio/Assignment-02/CMakeLists.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
|
||||
|
||||
# "ON" = build Option 1, "OFF" = build Option 2.
|
||||
option(BUILD_ASSIGNMENT_02_OPTION_1 "Build Assignment Option 1 (Standard)" ON)
|
||||
|
||||
add_executable(Assignment-02
|
||||
main.cpp
|
||||
)
|
||||
|
||||
# Conditionally add the correct source file
|
||||
if(BUILD_ASSIGNMENT_02_OPTION_1)
|
||||
# If ON, add option1.cpp and define 'ASSIGNMENT_OPTION=1' for C++
|
||||
target_sources(Assignment-02
|
||||
PRIVATE
|
||||
option1.cpp
|
||||
option1.h
|
||||
)
|
||||
target_compile_definitions(Assignment-02 PRIVATE "ASSIGNMENT_02_OPTION=1")
|
||||
else()
|
||||
# If OFF, add option2.cpp and define 'ASSIGNMENT_OPTION=2' for C++
|
||||
target_sources(Assignment-02
|
||||
PRIVATE
|
||||
option2.cpp
|
||||
option2.h
|
||||
)
|
||||
target_compile_definitions(Assignment-02 PRIVATE "ASSIGNMENT_02_OPTION=2")
|
||||
endif()
|
||||
target_link_libraries(Assignment-02
|
||||
PRIVATE
|
||||
SharedLib
|
||||
)
|
||||
|
||||
|
||||
add_custom_command(TARGET Assignment-02 POST_BUILD
|
||||
# Add a custom command here if needed
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Assignment-02 post-build step"
|
||||
)
|
||||
57
Exam/IKT203Exam/Portfolio/Assignment-02/main.cpp
Normal file
57
Exam/IKT203Exam/Portfolio/Assignment-02/main.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
// Mandatory-02.cpp : Defines the entry point for the application.
|
||||
//
|
||||
|
||||
/*
|
||||
Dear Student,
|
||||
|
||||
Remember to follow the coding standards and best practices discussed
|
||||
in the portfolio assignment document.
|
||||
Good luck with your portfolio!
|
||||
|
||||
NB: Do not delete the code below that prints the assignment and option info!
|
||||
|
||||
---------------------------------------------------------------------
|
||||
*** HOW TO SWITCH BETWEEN OPTION 1 AND OPTION 2 ***
|
||||
---------------------------------------------------------------------
|
||||
You CANNOT switch options by changing this file.
|
||||
|
||||
1. Go to the 'CMakeLists.txt' file for this assignment.
|
||||
2. Find the line:
|
||||
option(BUILD_ASSIGNMENT_OPTION_1 "..." ON)
|
||||
3. Change 'ON' (for Option 1) to 'OFF' (for Option 2).
|
||||
|
||||
*** VERY IMPORTANT: After changing the option ***
|
||||
Your project will NOT update until you re-run the CMake configuration.
|
||||
|
||||
To force an update (e.g., in Visual Studio):
|
||||
- Right-click the 'CMakeLists.txt' file and select 'Configure Cache'.
|
||||
- OR, simply delete the 'out' / 'build' folder and rebuild the project.
|
||||
---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string_view>
|
||||
|
||||
static constexpr std::string_view AssignmentName = "Category 2: Sorting & Searching";
|
||||
|
||||
#if ASSIGNMENT_02_OPTION == 1
|
||||
#include "option1.h"
|
||||
static constexpr std::string_view AssignmentOption = "Option 1 (Standard): Cruise Ship Manifest.";
|
||||
#elif ASSIGNMENT_02_OPTION == 2
|
||||
#include "option2.h"
|
||||
static constexpr std::string_view AssignmentOption = "Option 2 (Advanced): Combined Corporate Directory.";
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int appStatus = 0;
|
||||
std::cout << AssignmentName << std::endl;
|
||||
std::cout << AssignmentOption << std::endl;
|
||||
|
||||
// Create only core or common code in main.cpp
|
||||
// Use the option header files to implement the specific assignment option logic
|
||||
appStatus = RunApp();
|
||||
return appStatus;
|
||||
}
|
||||
36
Exam/IKT203Exam/Portfolio/Assignment-02/option1.cpp
Normal file
36
Exam/IKT203Exam/Portfolio/Assignment-02/option1.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
// Option 1 (Standard): Console Text Editor.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "option1.h"
|
||||
#include "SharedLib.h"
|
||||
|
||||
/**
|
||||
* @brief Callback function to process one name.
|
||||
*/
|
||||
static bool NameReadCallback(const int aIndex, const int aTotalCount, const std::string& aFirstName, const std::string& aLastName)
|
||||
{
|
||||
std::cout << "Reading Name " << (aIndex + 1) << " of " << aTotalCount << ": "
|
||||
<< aFirstName << " " << aLastName << "\n";
|
||||
|
||||
// We only want to read 10 names (index 0 through 9)
|
||||
// Return false when aIndex is 9 to stop the loop after this one.
|
||||
return (aIndex < 9);
|
||||
}
|
||||
|
||||
|
||||
int RunApp()
|
||||
{
|
||||
// Path to the names data file
|
||||
std::string filename = "F:\\IKT203\\VisualStudio\\DATA\\random_names.txt";
|
||||
|
||||
std::cout << "Reading first 10 names from file: " << filename << "\n\n";
|
||||
|
||||
// Call the utility function with the name callback
|
||||
readNamesFromFile(filename, NameReadCallback);
|
||||
|
||||
std::cout << "\nFinished reading names." << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
11
Exam/IKT203Exam/Portfolio/Assignment-02/option1.h
Normal file
11
Exam/IKT203Exam/Portfolio/Assignment-02/option1.h
Normal file
@@ -0,0 +1,11 @@
|
||||
// option1.h : Option 1 (Standard): Console Text Editor.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef OPTION1_H
|
||||
#define OPTION1_H
|
||||
|
||||
int RunApp();
|
||||
|
||||
|
||||
#endif // OPTION1_H
|
||||
8
Exam/IKT203Exam/Portfolio/Assignment-02/option2.cpp
Normal file
8
Exam/IKT203Exam/Portfolio/Assignment-02/option2.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// Option 2 (Advanced): Console Music Player.
|
||||
|
||||
#include "option2.h"
|
||||
|
||||
int RunApp() {
|
||||
// Implement the Console Music Player application logic here
|
||||
return 0;
|
||||
}
|
||||
10
Exam/IKT203Exam/Portfolio/Assignment-02/option2.h
Normal file
10
Exam/IKT203Exam/Portfolio/Assignment-02/option2.h
Normal file
@@ -0,0 +1,10 @@
|
||||
// option1.h : Option 2 (Advanced): Console Music Player.
|
||||
#pragma once
|
||||
|
||||
#ifndef OPTION2_H
|
||||
#define OPTION2_H
|
||||
|
||||
int RunApp();
|
||||
|
||||
|
||||
#endif // OPTION2_H
|
||||
Reference in New Issue
Block a user