diff --git a/templates/_folder_Exercises/O01/main.cpp b/templates/_folder_Exercises/O01/main.cpp deleted file mode 100644 index 861df2c..0000000 --- a/templates/_folder_Exercises/O01/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Øving 1 -// Oversettelse fra Python til C++ -#include "std_lib_facilities.h" - -int maxOfTwo(int a, int b) { - // BEGIN: 2a - - // END: 2a -} - -int fibonacci(int n) { - // BEGIN: 2c - - // END: 2c -} - -int squareNumberSum(int number) { - // BEGIN: 2d - - // END: 2d -} - -void triangleNumbersBelow(int number) { - // BEGIN: 2e - - // END: 2e -} - -bool isPrime(int number) { - // BEGIN: 2f - - // END: 2f -} - -void naivePrimeNumberSearch(int maxNumber) { - // BEGIN: 2g - - // END: 2g -} - -void inputAndPrintNameAndAge() { - // BEGIN: 2h - - // END: 2h -} - -int main() { - // BEGIN: 2b - - // END: 2b - return 0; -} diff --git a/templates/_folder_Exercises/O02/main.cpp b/templates/_folder_Exercises/O02/main.cpp deleted file mode 100644 index 0275bbc..0000000 --- a/templates/_folder_Exercises/O02/main.cpp +++ /dev/null @@ -1,102 +0,0 @@ -//handout oving 2 - -#include "std_lib_facilities.h" -#include "AnimationWindow.h" - - -void inputAndPrintInteger() { - // BEGIN: 1b - - // END: 1b -} - -int inputInteger() { - // BEGIN: 1c - return 0; - // END: 1c -} - -void printSumOfInputIntegers() { - // BEGIN: 1d - - // END: 1d -} - -bool isOdd(int n) { - // BEGIN: 1f - return 0; - // END: 1f -} - -void inputIntegersAndPrintSum() { - // BEGIN: 2a - - // END: 2a -} - -void inputIntegersAndPrintSumUntilStopped() { - // BEGIN: 2b - - // END: 2b -} - -double inputDouble() { - // BEGIN: 2d - return 0; - // END: 2d -} - -void convertNOKtoEUR() { - // BEGIN: 2e - - // END: 2e -} - -void printMultiplicationTable() { - // BEGIN: 2g - - // END: 2g -} - -double discriminant(double a, double b, double c) { - // BEGIN: 3a - return 0; - // END: 3a -} - -void printRealRoots(double a, double b, double c) { - // BEGIN: 3b - - // END: 3b -} - -void solveQuadraticEquations() { - // BEGIN: 3c - - // END: 3c -} - -void pythagoras() { - // BEGIN: 4a - // Alle deloppgaver i 4 skal løses her - // END: 4a -} - -vector calculateBalance(int amount, int rate, int years) { - // BEGIN: 5a - return {}; - // END: 5a -} - -void printBalance(vector balanceVec) { - // BEGIN: 5b - - // END: 5b -} - -int main() { - // Oppgave 1a - // Her kan du teste funksjonene dine ved hjelp av menysystem som beskrevet. - // NB: Denne delen av koden blir IKKE automatisk rettet. - return 0; -} diff --git a/templates/_folder_Exercises/O03/cannonball.cpp b/templates/_folder_Exercises/O03/cannonball.cpp deleted file mode 100644 index 66caa52..0000000 --- a/templates/_folder_Exercises/O03/cannonball.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "cannonball.h" -#include "cannonball_viz.h" -#include "utilities.h" - -// BEGIN: 2a -// Implementer funksjonen acclY -// END: 2a - -// BEGIN: 2b -// Implementer funksjonen velY -// END: 2b - -// BEGIN: 2c -// Implementer funksjonene posX og posY -// END: 2c - -// BEGIN: 2d -// Implementer funksjonen printTime -// END: 2d - -// BEGIN: 2e -// Implementer funksjonen flightTime -// END: 2e - -// BEGIN: 3b -// Implementer funksjonen testDeviation -// END: 3b - -// BEGIN: 4a -// Her skal du implementere ALLE funksjonene i oppgave 4a -// END: 4a - -// BEGIN: 4b - -// END: 4b - -// BEGIN: 4c - -// END: 4c - - -// BEGIN: 5b - -// END: 5b diff --git a/templates/_folder_Exercises/O03/cannonball.h b/templates/_folder_Exercises/O03/cannonball.h deleted file mode 100644 index 744f428..0000000 --- a/templates/_folder_Exercises/O03/cannonball.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once -#include "std_lib_facilities.h" - -constexpr double pi = 3.14159265; -constexpr double gravity = 9.81; - -// Del 1: - -// BEGIN: 1a -// Deklarer funksjonen acclY -// END: 1a - -// BEGIN: 1b -// Deklarer funksjonen velY -// END: 1b - -// BEGIN: 1c -// Deklarer funksjonene posX og posY -// END: 1c - -// BEGIN: 1d -// Deklarer funksjonen printTime -// END: 1d - -// BEGIN: 1e -// Deklarer funksjonen flightTime -// END: 1e - -bool testDeviation(double compareOperand, double toOperand, double maxError, string name); - -// Del 2: -// BEGIN: 4a -// Her skal du deklarere ALLE funksjonene i oppgave 4a -// END: 4a - -// BEGIN: 4b - -// END: 4b - -// BEGIN: 4c - -// END: 4c - -// Del 3: - -// BEGIN: 5b -// Deklarer funksjonen playTargetPractice her -// END: 5b diff --git a/templates/_folder_Exercises/O03/cannonball_viz.cpp b/templates/_folder_Exercises/O03/cannonball_viz.cpp deleted file mode 100644 index 4f928a7..0000000 --- a/templates/_folder_Exercises/O03/cannonball_viz.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// Utdelt kode, visualisering av cannonball-spillet i øving 3. - -#include "AnimationWindow.h" - -#include "cannonball_viz.h" -#include "cannonball.h" -// Pass på sirkulaer headerinkludering. -using namespace TDT4102; - -void cannonBallViz(double targetPosition, int fieldLength, double initVelocityX, double initVelocityY, - int timeSteps) -{ - /* - constexpr int w_width = 800; - constexpr int w_height = 500; - AnimationWindow window(100, 100, w_width, w_height, "Cannonball Visualizer"); //100, 100 angir x og y, som er overst til venstre i vinduet - window.keep_previous_frame(false); - - // forste tidssteg er 0 - for (int i = 0; i <= timeSteps; ++i) { - // Lag en ny frame ved starten av løkken slik at siste bildet er vist naar animasjonen er ferdig - window.next_frame(); - - // Plot target. targetPosition er [100, 1000] i main programmet - // denne funksjonen mapper 0 til 0, og fieldLength til w_width - int target_x = static_cast((targetPosition * w_width) / fieldLength); - window.draw_rectangle(Point{target_x - 10, w_height - 20}, 20, 20, Color::dark_green); - - double time = i * (flightTime(initVelocityY) / timeSteps); - - // maa skalere x til w_width, som beskrevet over - int xPos = static_cast(posX(0, initVelocityX, time) * w_width) / fieldLength; - window.draw_circle(Point{xPos, static_cast(w_height - posY(0, initVelocityY, time))}, 8, Color::red); - } - - std::cout << std::endl << "Close the window to continue." << std::endl; - window.wait_for_close(); - */ -} diff --git a/templates/_folder_Exercises/O03/cannonball_viz.h b/templates/_folder_Exercises/O03/cannonball_viz.h deleted file mode 100644 index 5f8577e..0000000 --- a/templates/_folder_Exercises/O03/cannonball_viz.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -void cannonBallViz(double targetPosition, - int fieldLength, - double initVelocityX, - double initVelocityY, - int timeSteps); diff --git a/templates/_folder_Exercises/O03/main.cpp b/templates/_folder_Exercises/O03/main.cpp deleted file mode 100644 index 5720f47..0000000 --- a/templates/_folder_Exercises/O03/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "std_lib_facilities.h" -#include "cannonball.h" - -int main() -{ - return 0; -} \ No newline at end of file diff --git a/templates/_folder_Exercises/O03/utilities.cpp b/templates/_folder_Exercises/O03/utilities.cpp deleted file mode 100644 index c375dbc..0000000 --- a/templates/_folder_Exercises/O03/utilities.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "utilities.h" -#include - -// BEGIN: 5a - -// END: 5a \ No newline at end of file diff --git a/templates/_folder_Exercises/O03/utilities.h b/templates/_folder_Exercises/O03/utilities.h deleted file mode 100644 index 26d4818..0000000 --- a/templates/_folder_Exercises/O03/utilities.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -// BEGIN: 5a -// Deklarer funksjonen randomWithLimits som tar inn et -// heltall som nedre grense som første argument og et heltall som øvre grense som andre argument. -// END: 5a \ No newline at end of file diff --git a/templates/_folder_Exercises/O04/main.cpp b/templates/_folder_Exercises/O04/main.cpp deleted file mode 100644 index 44bb3ed..0000000 --- a/templates/_folder_Exercises/O04/main.cpp +++ /dev/null @@ -1,12 +0,0 @@ - -#include "std_lib_facilities.h" -#include "test.h" - -int main() -{ - - // Her kan du teste koden og funksjonene dine, - // Ingenting som skrives her blir automatisk rettet, du tester her for din egen del - - return 0; -} diff --git a/templates/_folder_Exercises/O04/masterVisual.cpp b/templates/_folder_Exercises/O04/masterVisual.cpp deleted file mode 100644 index 98c48f0..0000000 --- a/templates/_folder_Exercises/O04/masterVisual.cpp +++ /dev/null @@ -1,147 +0,0 @@ -#include "masterVisual.h" - - -// i denne løses 5 a, d, g og litt av f -// BEGIN: 5 - -//void playMasterMindVisual(){} - -// END: 5 - - -void addGuess(MastermindWindow &mwin, const string code, const char startLetter) -{ - // BEGIN: 5b - - // END: 5b -} - -void addFeedback(MastermindWindow &mwin, const int correctPosition, const int correctCharacter) -{ - // BEGIN: 5e - - // END: 5e -} - -void MastermindWindow::drawCodeHider() -{ - if (code_hidden) { - draw_rectangle(Point{padX, 3 * padY}, winW - size * padX, padY, Color::black); - } -} - -MastermindWindow::MastermindWindow(int x, int y, int w, int h, int size, const string &title) -: AnimationWindow(x, y, w, h, title), -guessBtn{{upperLeftCornerBtn.x, upperLeftCornerBtn.y}, btnW, btnH, "Add"}, -guess{{upperLeftCornerInBox.x, upperLeftCornerInBox.y}, inBoxW, inBoxH, ""}, -size(size) -{ - add(guess); - add(guessBtn); - guessBtn.setCallback(std::bind(&MastermindWindow::cb_guess, this)); -}; - -void MastermindWindow::drawGuessesAndFeedbacks() -{ - std::map colorConverter{ - {1, Color::red}, - {2, Color::green}, - {3, Color::yellow}, - {4, Color::blue}, - {5, Color::blue_violet}, - {6, Color::dark_cyan}}; - - for (int guessIndex = 0; guessIndex < static_cast(guesses.size()); guessIndex++) - { - /*********************************************************************/ - - // BEGIN: 5c - - // Implementer funksjonalitet slik at det vises fargede rektangler i grafikkvinduet - // Legg merke til at vi er i et for-løkke som går gjennom alle gjettene som er gjort. - // Tegn gjettet som ligger på plassen guessIndex i vektoren guesses. - - - for (int i = 0; i < size; i++) - { - // Denne for-løkken går gjennom alle firkantene som skal tegnes i et gjett. - // Tegn rektangler ved bruk av draw_rectangle(). Bruk: colorConverter.at() for å få riktig farge - - } - // END: 5c - } - - for (int feedbackIndex = 0; feedbackIndex < static_cast(feedbacks.size()); feedbackIndex++) - { - /*********************************************************************/ - - // BEGIN: 5f - - // Implementer feedback - // Her skal mye likt gjøres som i 5c - - for (int i = 0; i < size; i++) - { - // Tegn sirkler ved hjelp av draw_circle(). - - } - // END: 5f - } -} - -string MastermindWindow::wait_for_guess() -{ - - while (!button_pressed && !should_close()) - { - drawGuessesAndFeedbacks(); - // Burde tegnes sist siden den skal ligge på toppen - drawCodeHider(); - - next_frame(); - } - button_pressed = false; - - string newGuess = guess.getText(); - guess.setText(""); - - return newGuess; -} - -string MastermindWindow::getInput(unsigned int n, char lower, char upper) -{ - bool validInput = false; - string guess; - while (!validInput && !should_close()) - { - guess.clear(); - string input = wait_for_guess(); - if (input.size() == n) - { - for (unsigned int i = 0; i < n; i++) - { - char ch = input.at(i); - if (isalpha(ch) && toupper(ch) <= upper && lower <= toupper(ch)) - { - guess += toupper(ch); - } - else - break; - } - } - if (guess.size() == n) - { - validInput = true; - } - else - { - cout << "Invalid input guess again" << endl; - } - } - return guess; -} - -void MastermindWindow::setCodeHidden(bool hidden) { - code_hidden = hidden; -} - diff --git a/templates/_folder_Exercises/O04/masterVisual.h b/templates/_folder_Exercises/O04/masterVisual.h deleted file mode 100644 index 70b209d..0000000 --- a/templates/_folder_Exercises/O04/masterVisual.h +++ /dev/null @@ -1,75 +0,0 @@ -#pragma once -#include "widgets/Button.h" -#include "widgets/TextInput.h" -#include "AnimationWindow.h" -#include "std_lib_facilities.h" - -using namespace TDT4102; - -// BEGIN: 5a -constexpr int winW = 0; // velg vindu bredde -constexpr int winH = 0; // velg vindu hoyde - -constexpr int padX = 0; // velg x skalering -constexpr int padY = 0; // velg y skalering -constexpr int radCircle = 0; // velg sirkel radius - -// END: 5a - -// BEGIN 5 -// deklarer playMasterMindVisual her -// END: 5 - - -constexpr int btnW = padX * 2; -constexpr int btnH = padY; -constexpr Point upperLeftCornerBtn = Point{winW - padX - btnW, padY}; - -constexpr int inBoxW = winW - 3 * padX - btnW; -constexpr int inBoxH = padY; -constexpr Point upperLeftCornerInBox = Point{padX, padY}; - -struct Guess { - const string code; - char startLetter = 'a'; -}; - -struct Feedback { - const int correctPosition = 0; - const int correctCharacter = 0; -}; - -// Her defineres klassen MastermindWindow, som arver fra klassen AnimationWindow. -// Det betyr at alle medlemsvariable og medlemsfunksjoner i AnimationWindow, også er en -// del av MastermindWindow. Du kan lese mer om klasser i kapittel 9.4 og om arv -// i kapittel 14.3 i læreboka. Dette skal du lære mer om senere i faget. -class MastermindWindow : public AnimationWindow -{ -public: - MastermindWindow(int x, int y, int w, int h, int size, const std::string &title); - - void cb_guess(){ newGuess(); } - - vector guesses; - vector feedbacks; - - void drawGuessesAndFeedbacks(); - - void setCodeHidden(bool hidden); - - string getInput(unsigned int n, char lower, char upper); - -private: - string wait_for_guess(); - void newGuess() { button_pressed = true; } - void drawCodeHider(); - - bool button_pressed = false; - bool code_hidden = true; - Button guessBtn; - TextInput guess; - int size = 0; -}; - -void addGuess(MastermindWindow &mwin, const string code, const char startLetter); -void addFeedback(MastermindWindow &mwin, const int correctPosition, const int correctCharacter); diff --git a/templates/_folder_Exercises/O04/mastermind.cpp b/templates/_folder_Exercises/O04/mastermind.cpp deleted file mode 100644 index fa73282..0000000 --- a/templates/_folder_Exercises/O04/mastermind.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "mastermind.h" - -// BEGIN: 4 -//Oppgave 4a til 4j løses her forutenom 4e og 4f -//playMastermind(){} -// END: 4 - -// BEGIN: 4e -///*returverdi*/ checkCharactersAndPosition(/*param 1: code, param 2: guess*/) {} -// END: 4e - -// BEGIN: 4f -///*returverdi*/ checkCharacters(/*param 1: code, param 2: guess*/) {} -// END: 4f diff --git a/templates/_folder_Exercises/O04/mastermind.h b/templates/_folder_Exercises/O04/mastermind.h deleted file mode 100644 index 13390cd..0000000 --- a/templates/_folder_Exercises/O04/mastermind.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "std_lib_facilities.h" -#include "utilities.h" - -// BEGIN: 4 -//deklarer playMastermind her -// END: 4 - -// BEGIN: 4e -//deklarer checkCharactersAndPosition her -// END: 4e - -// BEGIN: 4f -//deklarer checkCharacters her -// END: 4f diff --git a/templates/_folder_Exercises/O04/test.cpp b/templates/_folder_Exercises/O04/test.cpp deleted file mode 100644 index dda8380..0000000 --- a/templates/_folder_Exercises/O04/test.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "test.h" - -void testCallByValue() -{ - int v0 = 5; - int increment = 2; - int iterations = 10; - int result = incrementByValueNumTimes(v0, increment, iterations); - cout << "v0: " << v0 << " increment: " << increment - << " iterations: " << iterations << " result: " << result << '\n'; -} - -void testCallByReference() -{ - // BEGIN: 1d - - // END: 1d - -} - - -void testString(){ - // 3b OG 3e gjøres inne i her - // BEGIN: 3e - - // END: 3e -} \ No newline at end of file diff --git a/templates/_folder_Exercises/O04/test.h b/templates/_folder_Exercises/O04/test.h deleted file mode 100644 index 3b1a33f..0000000 --- a/templates/_folder_Exercises/O04/test.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once -#include "utilities.h" -#include "std_lib_facilities.h" - -void testCallByValue(); -void testCallByReference(); -void testString(); \ No newline at end of file diff --git a/templates/_folder_Exercises/O04/utilities.cpp b/templates/_folder_Exercises/O04/utilities.cpp deleted file mode 100644 index 73e0ff9..0000000 --- a/templates/_folder_Exercises/O04/utilities.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "utilities.h" - -int incrementByValueNumTimes(int startValue, int increment, int numTimes) -{ - for (int i = 0; i < numTimes; i++) - startValue += increment; - - return startValue; -} - -// BEGIN: 1d -///*returverdi*/ incrementByValueNumTimesRef(/*param 1: startValue(ref), param 2: increment, param 3: numtimes*/){} -// END: 1d - -// BEGIN: 1e -///*returverdi*/ swapNumbers(/*parametre*/){} -// END: 1e - -// BEGIN: 2b -///*returverdi*/ printStudent(/*input Student*/) {} -// END: 2b - -// BEGIN: 2c -///*returverdi*/ isInProgram(/*param 1: Student, param 2: string*/){} -// END: 2c - - -// BEGIN: 3a -///*returverdi*/ randomizeString(/*param 1: antall tegn, param 2: øvre grense, param 3: nedre grense */) -// END: 3a - -// BEGIN: 3c -///*returverdi*/ readInputToString(/*param 1: lengde n, param 2: øvre grense, param 3: nedre grense*/) -// END: 3c - -// BEGIN: 3d -///*returverdi*/ countChar(/*param 1: string, param 2: char*/) -// END: 3d diff --git a/templates/_folder_Exercises/O04/utilities.h b/templates/_folder_Exercises/O04/utilities.h deleted file mode 100644 index 4bd5719..0000000 --- a/templates/_folder_Exercises/O04/utilities.h +++ /dev/null @@ -1,39 +0,0 @@ - -#pragma once -#include "std_lib_facilities.h" - -// BEGIN: 1b - // deklarerer funksjonen incrementByValueNumTimes her -// END: 1b - -// BEGIN: 1d - // deklarerer funksjonen incrementByValueNumTimesRef her -// END: 1d - -// BEGIN: 1e - // deklarerer funksjonen swapNumbers her -// END: 1e - -// BEGIN: 2a - // lag struct Student her -// END: 2a - -// BEGIN: 2b -// deklarerer funksjonen printStudent her -// END: 2b - -// BEGIN: 2c -// deklarerer funksjonen isInProgram her -// END: 2c - -// BEGIN: 3a - // deklarerer funksjonen randomizeString her -// END: 3a - -// BEGIN: 3c - // deklarerer funksjonen readInputToString her -// END: 3c - -// BEGIN: 3d - // deklarerer funksjonen countChar her -// END: 3d diff --git a/templates/_folder_Exercises/O05/Blackjack.cpp b/templates/_folder_Exercises/O05/Blackjack.cpp deleted file mode 100644 index c0cbe06..0000000 --- a/templates/_folder_Exercises/O05/Blackjack.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "Blackjack.h" - -// Her kan du lage dine funksjons- og klasseimplementasjoner for å lage blackjack \ No newline at end of file diff --git a/templates/_folder_Exercises/O05/Blackjack.h b/templates/_folder_Exercises/O05/Blackjack.h deleted file mode 100644 index 0176646..0000000 --- a/templates/_folder_Exercises/O05/Blackjack.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -#include "CardDeck.h" - -// Her kan du lage dine funksjons- og klassedeklarasjoner for å lage blackjack diff --git a/templates/_folder_Exercises/O05/Card.cpp b/templates/_folder_Exercises/O05/Card.cpp deleted file mode 100644 index f9d04a3..0000000 --- a/templates/_folder_Exercises/O05/Card.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "Card.h" - -// BEGIN: 1c - -// END: 1c - -// BEGIN: 1d - -// END: 1d - -// BEGIN: 2b - -// END: 2b - -// BEGIN: 2c - -// END: 2c - -// BEGIN: 2d - -// END: 2d - -// BEGIN: 2e - -// END: 2e \ No newline at end of file diff --git a/templates/_folder_Exercises/O05/Card.h b/templates/_folder_Exercises/O05/Card.h deleted file mode 100644 index fa66fec..0000000 --- a/templates/_folder_Exercises/O05/Card.h +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once -#include "std_lib_facilities.h" - -// BEGIN: 1a - -// END: 1a - -// BEGIN: 1b - -// END: 1b - -/* -// Les deg opp på map og unordered_map i C++, og bruk disse map-ene -// for å konvertere mellom Rank/Suit og string i oppgavene videre -// Husk å fjern /* for å bruke map-ene -const map rankToStringMap { - {Rank::two, "two"}, - {Rank::three, "three"}, - {Rank::four, "four"}, - {Rank::five, "five"}, - {Rank::six, "six"}, - {Rank::seven, "seven"}, - {Rank::eight, "eight"}, - {Rank::nine, "nine"}, - {Rank::ten, "ten"}, - {Rank::jack, "jack"}, - {Rank::queen, "queen"}, - {Rank::king, "king"}, - {Rank::ace, "ace"} -}; - -const map SuitToStringMap { - {Suit::clubs, "clubs"}, - {Suit::diamonds, "diamonds"}, - {Suit::hearts, "hearts"}, - {Suit::spades, "spades"} -}; -*/ - -// BEGIN: 1c - -// END: 1c - -// BEGIN: 1d - -// END: 1d - -// BEGIN: 2a - -// END: 2a \ No newline at end of file diff --git a/templates/_folder_Exercises/O05/CardDeck.cpp b/templates/_folder_Exercises/O05/CardDeck.cpp deleted file mode 100644 index df73947..0000000 --- a/templates/_folder_Exercises/O05/CardDeck.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "CardDeck.h" - -// BEGIN: 3b - -// END: 3b - -// BEGIN: 3c - -// END: 3c - -// BEGIN: 3d - -// END: 3d - -// BEGIN: 3e - -// END: 3e - -// BEGIN: 3f - -// END: 3f diff --git a/templates/_folder_Exercises/O05/CardDeck.h b/templates/_folder_Exercises/O05/CardDeck.h deleted file mode 100644 index 4575f74..0000000 --- a/templates/_folder_Exercises/O05/CardDeck.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once -#include "Card.h" - -// BEGIN: 3a - -// END: 3a diff --git a/templates/_folder_Exercises/O05/main.cpp b/templates/_folder_Exercises/O05/main.cpp deleted file mode 100644 index 807c02e..0000000 --- a/templates/_folder_Exercises/O05/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "std_lib_facilities.h" - -int main() -{ - // Her skal du teste koden din underveis for å sikre deg at den funker slik forventet - return 0; -} \ No newline at end of file diff --git a/templates/_folder_Exercises/O06/CourseCatalog.cpp b/templates/_folder_Exercises/O06/CourseCatalog.cpp deleted file mode 100644 index d988143..0000000 --- a/templates/_folder_Exercises/O06/CourseCatalog.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "CourseCatalog.h" - -// BEGIN: 3a - -// END: 3a - -// BEGIN: 3b - -// END: 3b - -// BEGIN: 3c - -// END: 3c - -// BEGIN: 3d - -// END: 3d - -// BEGIN: 3e - -// END: 3e - -// BEGIN: 3g - -// END: 3g - -// BEGIN: 3h - -// END: 3h \ No newline at end of file diff --git a/templates/_folder_Exercises/O06/CourseCatalog.h b/templates/_folder_Exercises/O06/CourseCatalog.h deleted file mode 100644 index 2c8dce7..0000000 --- a/templates/_folder_Exercises/O06/CourseCatalog.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include "std_lib_facilities.h" - -class CourseCatalog -{ -public: - void addCourse(const string& key, const string& value); - void removeCourse(const string& key); - string getCourse(const string& key) const; - - friend ostream& operator<<(ostream& os, const CourseCatalog& cc); - - void saveToFile(const std::string& filename) const; - void loadFromFile(const std::string& filename); - -private: - map courses; -}; - -void testCourseCatalog(); \ No newline at end of file diff --git a/templates/_folder_Exercises/O06/FileUtils.cpp b/templates/_folder_Exercises/O06/FileUtils.cpp deleted file mode 100644 index fdcfb93..0000000 --- a/templates/_folder_Exercises/O06/FileUtils.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "FileUtils.h" - - -void writeUserInputToFile(const std::string &path) -{ - // BEGIN: 1a - - // END: 1a -} - - -void addLineNumbers(const std::string &filename) -{ - // BEGIN: 1b - - // END: 1b -} \ No newline at end of file diff --git a/templates/_folder_Exercises/O06/FileUtils.h b/templates/_folder_Exercises/O06/FileUtils.h deleted file mode 100644 index 1e8fdbf..0000000 --- a/templates/_folder_Exercises/O06/FileUtils.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once -#include "std_lib_facilities.h" - -void writeUserInputToFile(const std::string &filename); -void addLineNumbers(const std::string &filename); \ No newline at end of file diff --git a/templates/_folder_Exercises/O06/bouncingBall.cpp b/templates/_folder_Exercises/O06/bouncingBall.cpp deleted file mode 100644 index 57048a5..0000000 --- a/templates/_folder_Exercises/O06/bouncingBall.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#pragma once -#include "bouncingBall.h" - -// BEGIN: 4b - -// END: 4b - -// BEGIN: 4c - -// END: 4c - -constexpr Point BOUNCE_WINDOW_TOP_LEFT{50, 50}; -constexpr int BOUNCE_WINDOW_WIDTH{800}; -constexpr int BOUNCE_WINDOW_HEIGHT{500}; - -// FJERN DETTE NAAR DU BEGYNNER PÅ OPPGAVE 4e) -#define BOUNCING_BALL -// - -void bouncingBall(){ - #ifndef BOUNCING_BALL - AnimationWindow window{BOUNCE_WINDOW_TOP_LEFT.x, BOUNCE_WINDOW_TOP_LEFT.y, - BOUNCE_WINDOW_WIDTH, BOUNCE_WINDOW_HEIGHT, "Bouncing ball"}; - - const int radius{30}; - int alpha{1}; - int velocity{2}; - Color color_up{Color::blue}; - Color color_down{Color::blue}; - int x{0}; - int y{360}; - int increment_x{0}; - int increment_y{0}; - int count_bounce_top{0}; - int count_bounce_bottom{0}; - int count_num_passes{0}; - - Config slow = {1, 1, 0}; - Config fast = {1, 1, 0}; - - // read in the configurations - filesystem::path file_name{"konfigurasjon.txt"}; - ifstream is{file_name}; - is >> slow >> fast; - - // initialise the run - velocity = slow.velocity; - color_up = ball_color.at(slow.color_up); - color_down = ball_color.at(slow.color_down); - - while (!window.should_close()) { - // determine increments based on the velocity - increment_x = velocity * cos(alpha); - increment_y = velocity * sin(alpha); - - // movement i x-direction - if ((increment_x + x) > window.width()) { - // reached right side - wrap around to the leftmost - x = 0; - // increment counter which counts number of full left-to-right passes - count_num_passes++; - // alternate between slow and fast configuration every second pass - if (count_num_passes % 2 == 0) { - if (velocity == slow.velocity) { - velocity = fast.velocity; - color_up = ball_color.at(fast.color_up); - color_down = ball_color.at(fast.color_down); - } else { - velocity = slow.velocity; - color_up = ball_color.at(slow.color_up); - color_down = ball_color.at(slow.color_down); - } - } - } else { - // moving rightwards - x += increment_x; - } - - - // HINT 1: Ta en titt på koden ovenfor og se hvilke variabler som brukes. - // Bruk disse variablene for å implementere bevegelsen til den sprettende ballen. For eksempel: - // Variablene count_bounce_top og count_bounce_bottom kan brukes - // for å holde styr på hvilken retning ballen skal gå. - // Variabelen increment_y skal brukes for å øke y. - - // HINT 2: window.draw_circle({x, y}, r, c) tegner en sirkel med radius r, - // sentrum i (x, y) og fargen c - - // BEGIN: 4d - // movement in y-direction - // END: 4d - - window.next_frame(); - } - #endif -} \ No newline at end of file diff --git a/templates/_folder_Exercises/O06/bouncingBall.h b/templates/_folder_Exercises/O06/bouncingBall.h deleted file mode 100644 index 0018d5e..0000000 --- a/templates/_folder_Exercises/O06/bouncingBall.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "std_lib_facilities.h" -#include "AnimationWindow.h" - -struct Config{ - // BEGIN: 4a - - // END: 4a -}; - -extern map ball_color; - -istream& operator>>(istream& is, Config& cfg); - -void bouncingBall(); diff --git a/templates/_folder_Exercises/O06/konfigurasjon.txt b/templates/_folder_Exercises/O06/konfigurasjon.txt deleted file mode 100644 index 7043f2b..0000000 --- a/templates/_folder_Exercises/O06/konfigurasjon.txt +++ /dev/null @@ -1,2 +0,0 @@ -1 2 3 -3 4 15 \ No newline at end of file diff --git a/templates/_folder_Exercises/O06/main.cpp b/templates/_folder_Exercises/O06/main.cpp deleted file mode 100644 index 157771d..0000000 --- a/templates/_folder_Exercises/O06/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "std_lib_facilities.h" -#include "CourseCatalog.h" -#include "FileUtils.h" -#include "bouncingBall.h" - -int main() -{ - // Her kan du teste din kode ved å kalle på de ulike funksjonene du har implementert - return 0; -} \ No newline at end of file diff --git a/templates/_folder_Exercises/O07/Dummy.cpp b/templates/_folder_Exercises/O07/Dummy.cpp deleted file mode 100644 index 273c747..0000000 --- a/templates/_folder_Exercises/O07/Dummy.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "Dummy.h" -#include - -/* -void dummyTest() { - Dummy a; - *a.num = 4; - Dummy b{a}; - Dummy c; - c = a; - std::cout << "a: " << *a.num << '\n'; - std::cout << "b: " << *b.num << '\n'; - std::cout << "c: " << *c.num << '\n'; - - *b.num = 3; - *c.num = 5; - - std::cout << "a: " << *a.num << '\n'; - std::cout << "b: " << *b.num << '\n'; - std::cout << "c: " << *c.num << '\n'; -} -*/ \ No newline at end of file diff --git a/templates/_folder_Exercises/O07/Dummy.h b/templates/_folder_Exercises/O07/Dummy.h deleted file mode 100644 index ea53fc7..0000000 --- a/templates/_folder_Exercises/O07/Dummy.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include -/* -class Dummy { -public: - int *num; - - Dummy() { - num = new int{0}; - } - // BEGIN: 3c - - // END: 3c - - // Copy-Swap: Tar inn rhs som kopi, bytter medlemsvariable - // BEGIN: 3d - - // END: 3d - - ~Dummy() { - delete num; - } -}; - -void dummyTest(); -*/ \ No newline at end of file diff --git a/templates/_folder_Exercises/O07/DynamicMemory.cpp b/templates/_folder_Exercises/O07/DynamicMemory.cpp deleted file mode 100644 index 83cd995..0000000 --- a/templates/_folder_Exercises/O07/DynamicMemory.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -#include "DynamicMemory.h" - -// BEGIN: 1a - -// END: 1a - -// BEGIN: 1b - -// END: 1b - -// BEGIN: 1c - -// END: 1c \ No newline at end of file diff --git a/templates/_folder_Exercises/O07/DynamicMemory.h b/templates/_folder_Exercises/O07/DynamicMemory.h deleted file mode 100644 index f34c77e..0000000 --- a/templates/_folder_Exercises/O07/DynamicMemory.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -void fillInFibonacciNumbers(int* result, int length); -void printArray(int* array, int length); -void createFibonacci(); \ No newline at end of file diff --git a/templates/_folder_Exercises/O07/Matrix.cpp b/templates/_folder_Exercises/O07/Matrix.cpp deleted file mode 100644 index 980487b..0000000 --- a/templates/_folder_Exercises/O07/Matrix.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "Matrix.h" - -// BEGIN: 2b - -// END: 2b - -// BEGIN: 2c - -// END: 2c - -// Her kan du gjøre 2d (frivillig): - - -// BEGIN: 2f - -// END: 2f - - -// BEGIN: 4a - -// END: 4a - -// BEGIN: 4b - -// END: 4b - - -// BEGIN: 5a - -// END: 5a - -// BEGIN: 5b - -// END: 5b - - -void testMatrix() { - // Her kan du teste løsningen din (oppgave 5c): -} - -// Her kan du gjøre 5d (frivillig): \ No newline at end of file diff --git a/templates/_folder_Exercises/O07/Matrix.h b/templates/_folder_Exercises/O07/Matrix.h deleted file mode 100644 index 3d986a8..0000000 --- a/templates/_folder_Exercises/O07/Matrix.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once -#include -#include - - -class Matrix { -private: -// BEGIN: 2a - -// END: 2a -public: - // BEGIN: 2b - - // END: 2b - - // BEGIN: 2c - - // END: 2c - - // Her kan du gjøre 2d (frivillig): - - - // BEGIN: 2e - - // END: 2e - - - // BEGIN: 4a - - // END: 4a - - // BEGIN: 4b - - // END: 4b - - - // BEGIN: 5a - - // END: 5a - - // BEGIN: 5b - - // END: 5b - - // Her kan du gjøre 5d (frivillig): - -}; - - -// BEGIN: 2f - -// END: 2f - -void testMatrix(); diff --git a/templates/_folder_Exercises/O07/main.cpp b/templates/_folder_Exercises/O07/main.cpp deleted file mode 100644 index 99696ab..0000000 --- a/templates/_folder_Exercises/O07/main.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include "DynamicMemory.h" -#include "Matrix.h" -#include "Dummy.h" - -int main() { - return 0; -} \ No newline at end of file diff --git a/templates/_folder_Exercises/O08/Car.cpp b/templates/_folder_Exercises/O08/Car.cpp deleted file mode 100644 index a6443f0..0000000 --- a/templates/_folder_Exercises/O08/Car.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "Car.h" - -#include - -// BEGIN 1b - -// END 1b - -// BEGIN 1c - -// END 1c \ No newline at end of file diff --git a/templates/_folder_Exercises/O08/Car.h b/templates/_folder_Exercises/O08/Car.h deleted file mode 100644 index b46aa81..0000000 --- a/templates/_folder_Exercises/O08/Car.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -// BEGIN: 1a - -// END: 1a \ No newline at end of file diff --git a/templates/_folder_Exercises/O08/Meeting.cpp b/templates/_folder_Exercises/O08/Meeting.cpp deleted file mode 100644 index 23c4eec..0000000 --- a/templates/_folder_Exercises/O08/Meeting.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "Meeting.h" - -#include -#include -#include -#include -#include - -// BEGIN 3b - -// END 3b - -// BEGIN 3e - -// END 3e - -// BEGIN 3f - -// END 3f - -// BEGIN 3h - -// END 3h - -// BEGIN 3i - -// END 3i - -// BEGIN 3j - -// END 3j diff --git a/templates/_folder_Exercises/O08/Meeting.h b/templates/_folder_Exercises/O08/Meeting.h deleted file mode 100644 index 8237e13..0000000 --- a/templates/_folder_Exercises/O08/Meeting.h +++ /dev/null @@ -1,67 +0,0 @@ -#pragma once - -#include "Person.h" - -#include -#include -#include -#include -#include -#include - -// BEGIN 3a -enum class Campus {}; -// END 3a - -// BEGIN 3b - -// END 3b - -// FJERN KOMMENTAR NAAR DU SKAL BRUKE -/* -const std::unordered_map campusToString { - { Campus::trh, "Trondheim" }, - { Campus::aal, "Aalesund" }, - { Campus::gjo, "Gjovik"} -}; - -const std::unordered_map stringToCampus { - { "Trondheim", Campus::trh }, - { "Aalesund", Campus::aal }, - { "Gjovik", Campus::gjo } -}; -*/ - -class Meeting -{ -private: - // BEGIN 3c - - // END 3c -public: - // BEGIN 3d - - // END 3d - - // BEGIN 3e - - // END 3e - - Meeting(int day, int startTime, int endTime, Campus location, const std::string& subject, const std::shared_ptr leader); - - // BEGIN 3h - - // END 3h - - // BEGIN 3i - - // END 3i - - // Vi ønsker ikke å tillate kopiering av Meeting-objekter - Meeting(const Meeting&) = delete; - Meeting& operator=(const Meeting&) = delete; -}; - -// BEGIN 3j - -// END 3j \ No newline at end of file diff --git a/templates/_folder_Exercises/O08/MeetingWindow.cpp b/templates/_folder_Exercises/O08/MeetingWindow.cpp deleted file mode 100644 index 73e6bcc..0000000 --- a/templates/_folder_Exercises/O08/MeetingWindow.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "MeetingWindow.h" -#include - -MeetingWindow::MeetingWindow(TDT4102::Point position, int width, int height, const std::string& title): - // BEGIN 4a - AnimationWindow{}, - // END 4a - - // BEGIN 4e - - // END 4e - - // BEGIN 5a - #define FOUR_A - // END 5a - - // BEGIN 5b - #define FOUR_B - // END 5b - - dummyArgument{0} -{ - // Felles - // BEGIN 4f - - // END 4f - - // BEGIN 4g - - // END 4g - - // BEGIN 5d - - // END 5d - - // Ny person - #ifndef FOUR_A - attachPersonWidget(personName); - attachPersonWidget(personEmail); - #endif - - #ifndef FOUR_B - attachPersonWidget(personSeats); - attachPersonWidget(personNewBtn); - #endif -} - -// Callbackfunksjoner -// BEGIN 4d - -// END 4d - -// BEGIN 5c - -// END 5c - -void MeetingWindow::attachPersonWidget(TDT4102::Widget& pw) -{ - add(pw); - personWidgets.emplace_back(std::ref(pw)); -} \ No newline at end of file diff --git a/templates/_folder_Exercises/O08/MeetingWindow.h b/templates/_folder_Exercises/O08/MeetingWindow.h deleted file mode 100644 index e93f6de..0000000 --- a/templates/_folder_Exercises/O08/MeetingWindow.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#include "AnimationWindow.h" -#include "Meeting.h" -#include "Person.h" -#include "widgets/Button.h" -#include "widgets/TextInput.h" -#include "widgets/DropdownList.h" - -#include -#include -#include - - -// Meeting GUI -class MeetingWindow : public TDT4102::AnimationWindow -{ - public: - // BEGIN 4c - - // END 4c - - MeetingWindow(TDT4102::Point position, int width, int height, const std::string& title); - - // Avslutt knapp - // BEGIN 4e - - // END 4e - - // Callback-funksjoner - // BEGIN 4d - - // END 4d - - // Person - // BEGIN 5a - - // END 5a - - // BEGIN 5b - - // END 5b - - // Personer - // BEGIN 5c - - // END 5c - - int dummyArgument; - - // Hjelpefunksjoner og variabler - void attachPersonWidget(TDT4102::Widget& pw); - std::vector> personWidgets; -}; diff --git a/templates/_folder_Exercises/O08/Person.cpp b/templates/_folder_Exercises/O08/Person.cpp deleted file mode 100644 index 2d60bda..0000000 --- a/templates/_folder_Exercises/O08/Person.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "Person.h" - -// BEGIN 2b - -// END 2b - -// BEGIN 2c - -// END 2c - -// BEGIN 2d - -// END 2d diff --git a/templates/_folder_Exercises/O08/Person.h b/templates/_folder_Exercises/O08/Person.h deleted file mode 100644 index a633cf6..0000000 --- a/templates/_folder_Exercises/O08/Person.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -#include "Car.h" -#include -#include -#include - -class Person -{ -public: - // BEGIN 2b - - // END 2b - - // BEGIN 2c - - // END 2c - - // BEGIN 2d - - // END 2d - - // Vi onsker ikke å tillate kopiering av Person-objekter - Person(const Person&) = delete; - Person& operator=(const Person&) = delete; - -private: - // BEGIN 2a - - // END 2a -}; diff --git a/templates/_folder_Exercises/O08/main.cpp b/templates/_folder_Exercises/O08/main.cpp deleted file mode 100644 index 84dcc4c..0000000 --- a/templates/_folder_Exercises/O08/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "Person.h" -#include "Meeting.h" -#include "MeetingWindow.h" -#include - -int main() -{ - // Her kan du teste koden din - return 0; -} diff --git a/templates/_folder_Exercises/O09/MyArray.cpp b/templates/_folder_Exercises/O09/MyArray.cpp deleted file mode 100644 index ddddc29..0000000 --- a/templates/_folder_Exercises/O09/MyArray.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "MyArray.h" - -// BEGIN 5d - -// END 5d \ No newline at end of file diff --git a/templates/_folder_Exercises/O09/MyArray.h b/templates/_folder_Exercises/O09/MyArray.h deleted file mode 100644 index 52b370f..0000000 --- a/templates/_folder_Exercises/O09/MyArray.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include -#include - -// BEGIN 5a - -// END 5a -class MyArray -{ - private: - // BEGIN 5b - - // END 5b - public: - // BEGIN 5c - - // END 5c -}; - -// BEGIN 5d - -// END 5d \ No newline at end of file diff --git a/templates/_folder_Exercises/O09/Stopwatch.cpp b/templates/_folder_Exercises/O09/Stopwatch.cpp deleted file mode 100644 index a4be1c7..0000000 --- a/templates/_folder_Exercises/O09/Stopwatch.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "Stopwatch.h" - -void Stopwatch::start() { - startTime = std::chrono::steady_clock::now(); -} - -double Stopwatch::stop() { - std::chrono::time_point endTime = std::chrono::steady_clock::now(); - long durationInMicroseconds = std::chrono::duration_cast(endTime - startTime).count(); - double durationInSeconds = double(durationInMicroseconds)/1000000.0; - return durationInSeconds; -} \ No newline at end of file diff --git a/templates/_folder_Exercises/O09/Stopwatch.h b/templates/_folder_Exercises/O09/Stopwatch.h deleted file mode 100644 index 5d7b1c3..0000000 --- a/templates/_folder_Exercises/O09/Stopwatch.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include - -// This class abstracts some (somewhat) nasty code that is -// definitely outside the scope of this course. -// Its main purpose is to return the amount of time -// taken by the program in main.cpp - -// Calling start() starts the stopwatch -// Calling stop() stops it and returns the amount of time -// that has elapsed since start() was called in seconds - -class Stopwatch { - std::chrono::time_point startTime; - -public: - void start(); - double stop(); -}; \ No newline at end of file diff --git a/templates/_folder_Exercises/O09/main.cpp b/templates/_folder_Exercises/O09/main.cpp deleted file mode 100644 index a646b82..0000000 --- a/templates/_folder_Exercises/O09/main.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "Stopwatch.h" -#include "measurePerformance.h" -#include "optimizeVector.h" -#include "optimizationTask.h" -#include "templatefunctions.h" -#include "MyArray.h" - - - -int main() { - // Oppgave 1 - //measurePerformanceUnique(); - //measurePerformanceShared(); - //measurePerformanceStack(); - //measurePerformanceHeap(); - - // Oppgave 2 - //optimizeVector(); - - // Oppgave 3 - //optimizationTask(); - - // Oppgave 4 - //testTemplateFunctions(); - - // Oppgave 5 - //testMyArray(); - return 0; -} \ No newline at end of file diff --git a/templates/_folder_Exercises/O09/measurePerformance.cpp b/templates/_folder_Exercises/O09/measurePerformance.cpp deleted file mode 100644 index e1117bd..0000000 --- a/templates/_folder_Exercises/O09/measurePerformance.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "Stopwatch.h" -#include -#include -#include - - -// BEGIN 1a - -// END 1a \ No newline at end of file diff --git a/templates/_folder_Exercises/O09/measurePerformance.h b/templates/_folder_Exercises/O09/measurePerformance.h deleted file mode 100644 index aa67ec7..0000000 --- a/templates/_folder_Exercises/O09/measurePerformance.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -double measurePerformanceUnique(); -double measurePerformanceShared(); - -double measurePerformanceStack(); -double measurePerformanceHeap(); diff --git a/templates/_folder_Exercises/O09/optimizationTask.cpp b/templates/_folder_Exercises/O09/optimizationTask.cpp deleted file mode 100644 index 8516f47..0000000 --- a/templates/_folder_Exercises/O09/optimizationTask.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "Stopwatch.h" -#include -#include - -// Utdelt program til oppgave 3 - -// BEGIN 3b -double sumMatrix(std::vector> matrix){ - double sum = 0; - for (int row = 0; row < matrix.size(); row++){ - for (int col = 0; col < matrix.size(); col++){ - double value = matrix.at(row).at(col); - sum += value; - } - } - return sum; -} - -void setDiagonalValue(std::vector>& matrix, double newValue){ - for (int row = 0; row < matrix.size(); row++){ - for (int col = 0; col < matrix.size(); col++){ - bool isDiagonal = (row == col); - if (isDiagonal){ - matrix.at(row).at(col) = newValue; - } - } - } -} - -void optimizationTask(){ - Stopwatch stopwatch; - stopwatch.start(); - const int matrixSize = 10000; - - // Oppretter nullmatrisen direkte ved bruk av konstruktøren som tar inn antall og verdi. - std::vector> matrix(matrixSize, std::vector(matrixSize, 0.0)); - - // Setter alle elementer på diagonalen til 0.41 - setDiagonalValue(matrix, 0.41); - - // Summerer alle elementene i matrisen - double total = sumMatrix(matrix); - - double coolerNumber = total + 2; - std::cout << "TDT" << coolerNumber << std::endl; - - std::cout << "Time taken: " << stopwatch.stop() << "seconds" << std::endl; -} -// END 3b \ No newline at end of file diff --git a/templates/_folder_Exercises/O09/optimizationTask.h b/templates/_folder_Exercises/O09/optimizationTask.h deleted file mode 100644 index cf78e2f..0000000 --- a/templates/_folder_Exercises/O09/optimizationTask.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -void optimizationTask(); \ No newline at end of file diff --git a/templates/_folder_Exercises/O09/optimizeVector.cpp b/templates/_folder_Exercises/O09/optimizeVector.cpp deleted file mode 100644 index 408642e..0000000 --- a/templates/_folder_Exercises/O09/optimizeVector.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "Stopwatch.h" -#include "optimizeVector.h" -#include -#include - - -// BEGIN 2a - -// END 2a - - -void optimizeVector(){ - // BEGIN 2d - - // END 2d - - // BEGIN 2e - - // END 2e -} \ No newline at end of file diff --git a/templates/_folder_Exercises/O09/optimizeVector.h b/templates/_folder_Exercises/O09/optimizeVector.h deleted file mode 100644 index 2bb4d01..0000000 --- a/templates/_folder_Exercises/O09/optimizeVector.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -void testVector(); -void optimizeVector(); \ No newline at end of file diff --git a/templates/_folder_Exercises/O09/templatefunctions.cpp b/templates/_folder_Exercises/O09/templatefunctions.cpp deleted file mode 100644 index dc4e46d..0000000 --- a/templates/_folder_Exercises/O09/templatefunctions.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "templatefunctions.h" - -void testTemplateFunctions(){ - // Her kan du teste templatefunksjonene dine -} diff --git a/templates/_folder_Exercises/O09/templatefunctions.h b/templates/_folder_Exercises/O09/templatefunctions.h deleted file mode 100644 index dbbbc81..0000000 --- a/templates/_folder_Exercises/O09/templatefunctions.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include -#include -#include -#include - -// BEGIN 4a - -// END 4a - -// BEGIN 4b - -// END 4b - -void testTemplateFunctions(); \ No newline at end of file