Compare commits

...

38 Commits

Author SHA1 Message Date
Matti
61188b5afd Update README.md 2024-12-12 00:23:47 +01:00
Matti
e911510523 Remove Unused Code 2024-12-12 00:19:19 +01:00
Matti
ff499e51d8 Feature complete? 2024-12-12 00:07:26 +01:00
Matti
50e86d6ed5 Access Status VERY Illegally 2024-12-12 00:01:55 +01:00
Matti
bbad0349e4 Access Name Illegally 2024-12-11 23:45:28 +01:00
Matti
c26dc8415d Add Basic Reading 2024-12-11 23:36:38 +01:00
Matti
03ac04c0ff Include Link to CSV-Download 2024-11-23 09:49:35 +01:00
Matti
b99e0b45ad Add Aufg8 2024-11-23 09:43:41 +01:00
Matti
00b4e196da Change to giant if-else Chain 2024-11-23 09:39:58 +01:00
Matti
a0f05d9130 Use Switch Statement to handle String Cases (Doesnt Work) 2024-11-23 09:32:27 +01:00
Matti
bff9cf5935 Implement Counting Sales 2024-11-23 08:43:25 +01:00
Matti
9321ec8d71 Improve Map access 2024-11-23 08:12:49 +01:00
Matti
dbdd4ade8e Use Big File 2024-11-23 07:51:26 +01:00
Matti
e6fedd165e Implement counting Online vs Offline 2024-11-23 07:27:03 +01:00
Matti
8af59118c2 Implement getting most popular type in a country 2024-11-22 15:41:12 +01:00
Matti
2e4efa7833 Menu works? 2024-11-22 15:19:33 +01:00
Matti
68e7176d2e Add SalesStat Main Logic 2024-11-22 14:52:35 +01:00
Matti
92e69846f7 Add Menu Manager 2024-11-22 14:52:07 +01:00
Matti
763bc1c53e Actually return a string in toString 2024-11-21 22:58:04 +01:00
Matti
6bfaa038a7 Add Constructor, File Reading and to_String 2024-11-21 22:38:07 +01:00
Matti
641795f36f Add SalesStats 2024-11-21 22:04:40 +01:00
Matti
79a6afc2b5 Improve Insult 2024-11-21 17:11:13 +01:00
Matti
d87c3f5118 Add SEGV Creator / Handler 2024-11-21 17:06:47 +01:00
Matti
906f50e4a8 Delete VS Files 2024-11-21 10:29:51 +01:00
Matti
b664eee9dd Update README.md 2024-11-21 10:20:32 +01:00
Matti
775144421e Fix Bug and add second counting variant 2024-11-21 10:09:25 +01:00
Matti
e95f7f74d2 Bugfixes: Now Always deploys 99 Bombs and doesnt print random number in [0][0] 2024-11-15 23:09:54 +01:00
Matti
ebb8e43e32 Add Minesweeper and Bug Screenshots 2024-11-15 01:57:31 +01:00
Matti
98808ae921 Update Readme 2024-11-13 23:00:16 +01:00
Matti
d06d1021be Remove Comments / TODO and set default values 2024-11-13 22:54:51 +01:00
Matti
f37af51671 Bugfix, 0 correct doesnt end the game 2024-11-13 22:49:44 +01:00
Matti
df6e679963 Feature Complete? 2024-11-13 22:37:30 +01:00
Matti
253a2daeac Improve Match Counting 2024-11-13 22:18:09 +01:00
Matti
c38e15ded6 Implement Counting Matches 2024-11-13 21:52:30 +01:00
Matti
f5ce0edf4c Implement Counting perfect Matches 2024-11-13 21:29:55 +01:00
Matti
1d32b4798d Implement Getting Code from Console 2024-11-13 21:23:01 +01:00
Matti
90b0e5bd19 Add v1 of Console Input Method 2024-11-13 21:11:45 +01:00
Matti
b555d3d5c8 Basic Layout and implementations of Mastermind Helper Methods 2024-11-13 21:05:16 +01:00
21 changed files with 831 additions and 198 deletions

View File

@@ -5,10 +5,20 @@
#include "Aufg2/GuestList.h"
#include "Aufg3/Phonebook.h"
#include "Aufg4/CrimeStats.h"
#include "Aufg5/Mastermind.h"
#include "Aufg6/MineSweeper.h"
#include "Aufg7/SegFault.h"
#include "Aufg8/SalesStatMain.h"
#include "Aufg9/DiabloByteReader.h"
int main() {
// Aufg1Main();
// Aufg2Main();
// Aufg3Main();
Aufg4Main();
}
// Aufg4Main();
// Aufg5Main();
// Aufg6Main();
// Aufg7Main();
// Aufg8Main();
Aufg9Main();
}

136
Aufg5/Mastermind.cpp Normal file
View File

@@ -0,0 +1,136 @@
//
// Created by DH10MBO on 13.11.2024.
//
#include "Mastermind.h"
#include <iostream>
#include <ostream>
#include <random>
#include "../Aufg4/CrimeStats.h"
int getRandomNumberInRange(int min, int max) {
static std::mt19937 generator(static_cast<unsigned int>(time(nullptr)));
std::uniform_int_distribution<int> distribution(min, max);
int randomNumber = distribution(generator);
return randomNumber;
}
void printAllStringsInVector(std::vector<std::string> &strings) {
std::cout << "[";
int i;
for (i = 0; i < strings.size() - 1; i++) {
std::cout << strings[i] << ", ";
}
std::cout << strings[i] << "]" << std::endl;
}
std::vector<std::string> generateSecretCode(int digits, int optionsPerDigit) {
std::vector<std::string> secretCode;
for (int i = 0; i < digits; i++) {
int digit = getRandomNumberInRange(1, optionsPerDigit);
secretCode.push_back(std::to_string(digit));
}
return secretCode;
}
std::vector<std::string> getCodeGuessFromConsole(int codeLength, int livesRemaining) {
std::cout << "Have a Guess!" << std::endl;
std::cout << "You have " << livesRemaining << " more Attempts before you will be roasted" << std::endl;
std::vector<std::string> guess;
for (int i = 1; i <= codeLength; ++i) {
std::string input;
std::cin >> input;
guess.push_back(input);
}
std::cout << "You entered: " << std::endl;
printAllStringsInVector(guess);
return guess;
}
int countPefectMatches(std::vector<std::string> &v1, std::vector<std::string> &v2) {
int shorterSize;
if (v1.size() < v2.size()) {
shorterSize = v1.size();
} else {
shorterSize = v2.size();
}
int count = 0;
for (int i = 0; i < shorterSize; i++) {
if (v1[i] == v2[i]) {
count++;
}
}
return count;
}
int countMatches(std::vector<std::string> &v1, std::vector<std::string> &v2) {
int shorterSize;
if (v1.size() < v2.size()) {
shorterSize = v1.size();
} else {
shorterSize = v2.size();
}
std::vector<std::string> copyOfv2 = v2;
int count = 0;
for (int i = 0; i < shorterSize; i++) {
for (int j = 0; j < shorterSize; j++) {
if (v1[i] == copyOfv2[j]) {
count++;
copyOfv2[j] = "I have been counted already";
break;
}
}
}
return count;
}
void Aufg5Main() {
int optionsPerDigit = 4;
int codeLength = 4;
int livesRemaining = 6;
std::cout << optionsPerDigit << " options per Digit" << std::endl;
std::cout << codeLength << " Code Length" << std::endl;
std::cout << livesRemaining << " Lives Remaining" << std::endl;
std::cout << "======================================" << std::endl;
std::vector<std::string> SecretCode = generateSecretCode(codeLength, optionsPerDigit);
std::cout << "I have locked the door with a secret Code, you will never be able to figure it out!!" << std::endl;
while (livesRemaining) {
std::vector<std::string> guess = getCodeGuessFromConsole(codeLength, livesRemaining);
int perfectCounter = countPefectMatches(guess, SecretCode);
std::cout << "correct were: " << countMatches(guess, SecretCode) << std::endl;
std::cout << "perfect were: " << perfectCounter << std::endl << std::endl;
livesRemaining--;
if (perfectCounter == codeLength) {
std::cout << "No! This cant be!" << std::endl << "How did you know???" << std::endl << "What kind of Computer Nerd are you?!?";
return;
}
}
std::cout << "You Lost!" << std::endl << "My Secret Code stays a Mystery!!!" << std::endl << std::endl << "Fine, I will tell you" << std::endl;
printAllStringsInVector(SecretCode);
std::cout << "NERD ㄟ(≧◇≦)ㄏ";
}

24
Aufg5/Mastermind.h Normal file
View File

@@ -0,0 +1,24 @@
//
// Created by DH10MBO on 13.11.2024.
//
#ifndef MASTERMIND_H
#define MASTERMIND_H
#include <string>
#include <vector>
void Aufg5Main();
std::vector<std::string> generateSecretCode(int size, int optionsPerDigit);
int getRandomNumberInRange(int min, int max);
std::vector<std::string> getCodeGuessFromConsole();
std::vector<std::string> convertStringToGuess(std::string &guessAsString);
int countMatches(std::vector<std::string> &v1, std::vector<std::string> &v2);
int countPefectMatches(std::vector<std::string> &v1, std::vector<std::string> &v2);
#endif //MASTERMIND_H

BIN
Aufg6/Bullshit_Bug.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
Aufg6/Bullshit_Bug2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

102
Aufg6/MineSweeper.cpp Normal file
View File

@@ -0,0 +1,102 @@
#include <iostream>
#include "../Aufg5/Mastermind.h"
struct MineSweeperBoard {
std::string field[16][16];
int bombCounter = 0;
void debugBoard(std::string character) {
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
field[i][j] = character;
}
}
}
bool hasBomb(int i1, int i2) {
return field[i1][i2] == "x";
}
void spreadBombs() {
while (bombCounter < 99) {
short x = getRandomNumberInRange(0,15);
short y = getRandomNumberInRange(0,15);
if (field[x][y] != "x") {
field[x][y] = "x";
bombCounter++;
}
}
}
std::string countNeighbourBombs(int i, int j) {
i--;
j--;
int counter = 0;
// int counter; // Not setting this nerd to 0 can cause a bug
for (int k = 0; k < 3; k++) {
for (int l = 0; l < 3; l++) {
if ((i+k < 16) && (j+l < 16) && (i+l >= 0) && (j+l >= 0)) {
// if ((i+k < 16) && (j+l < 16) && (i-l >= 0) && (j-l >= 0)) {
if (field[i+k][j+l] == "x") {
counter++;
}
}
}
}
return std::to_string(counter);
}
std::string countNeighbourBombsBetter(int i, int j) {
int counter = 0;
// int counter; // Not setting this nerd to 0 can cause a bug
for (int k = -1; k <= 1; k++) {
for (int l = -1; l <= 1; l++) {
if ((i+k < 16) && (j+l < 16) && (i+l >= 0) && (j+l >= 0)) {
if (field[i+k][j+l] == "x") {
counter++;
}
}
}
}
return std::to_string(counter);
}
void calculateExplosiveNeighbours() {
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
if (field[i][j] != "x") {
field[i][j] = countNeighbourBombs(i, j);
}
}
}
}
void printBoard() {
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
std::cout << field[i][j] << " ";
}
std::cout << std::endl;
}
}
};
void Aufg6Main() {
MineSweeperBoard board;
board.printBoard();
std::cout << "Empty Board? ==============" << std::endl << std::endl;
board.spreadBombs();
board.printBoard();
std::cout << "Bombed Board? ==============" << std::endl << std::endl;
board.calculateExplosiveNeighbours();
board.printBoard();
std::cout << "Solved Board? ==============" << std::endl << std::endl;
board.debugBoard(".");
board.field[14][14] = "x";
board.field[13][13] = "x";
board.field[13][15] = "x";
board.calculateExplosiveNeighbours();
board.printBoard();
}

10
Aufg6/MineSweeper.h Normal file
View File

@@ -0,0 +1,10 @@
//
// Created by DH10MBO on 15.11.2024.
//
#ifndef MINESWEEPER_H
#define MINESWEEPER_H
void Aufg6Main();
#endif //MINESWEEPER_H

20
Aufg7/SegFault.cpp Normal file
View File

@@ -0,0 +1,20 @@
#include <csignal>
#include <iostream>
#include <ostream>
namespace {
volatile std::sig_atomic_t gSignalStatus;
}
void signal_handler(int sig) {
gSignalStatus = sig;
std::cout << "Du programmierst auch wie einer der auf Fußbilder von West-somalischen Piraten abfährt";
}
int Aufg7Main() {
signal(SIGSEGV, signal_handler);
int* a = nullptr;
*a = 2;
}

10
Aufg7/SegFault.h Normal file
View File

@@ -0,0 +1,10 @@
//
// Created by DH10MBO on 21.11.2024.
//
#ifndef SEGFAULT_H
#define SEGFAULT_H
int Aufg7Main();
#endif //SEGFAULT_H

32
Aufg8/MenuManager.cpp Normal file
View File

@@ -0,0 +1,32 @@
#include <iostream>
#include <stdlib.h>
class MenuManager {
// public:
// MenuManager();
// int AcceptIntInputInRange(int minInput, int maxInput) {
// int input;
// std::cin >> input;
//
// while (input < minInput || input > maxInput) {
// std::cout << "Enter a number between " << minInput << " and " << maxInput << ": ";
// std::cin >> input;
// }
// return input;
// }
//
// int ShowMainMenu() {
// system("cls");
//
// std::cout<<"Select Information to display" <<std::endl
// << "1. Profit per Metric" <<std::endl
// << "2. Cunt Sales of type X in a Region" <<std::endl
// << "3. Most popular item type in country X" <<std::endl
// << "4. Online vs Offline Sales in country X" <<std::endl
// << "======" <<std::endl
// << "0 to Exit" <<std::endl;
//
// int choice = AcceptIntInputInRange(0,4);
// return choice;
// }
};

79
Aufg8/MenuManager.h Normal file
View File

@@ -0,0 +1,79 @@
//
// Created by DH10MBO on 21.11.2024.
//
#ifndef MENUMANAGER_H
#define MENUMANAGER_H
#include <iostream>
class MenuManager {
private:
int * currentMenu;
std::string * selectedMetric;
std::string * selectedRegion;
public:
MenuManager(int * currentMenu, std::string * selectedMetric, std::string * selectedRegion){
this->currentMenu = currentMenu;
this->selectedRegion = selectedRegion;
this->selectedMetric = selectedMetric;
}
int AcceptIntInputInRange(int minInput, int maxInput) {
int input;
std::cin >> input;
while (input < minInput || input > maxInput) {
std::cout << "Enter a number between " << minInput << " and " << maxInput << ": ";
std::cin >> input;
}
return input;
}
int ShowMainMenu() {
// system("cls");
std::cout<<"Select Information to display" <<std::endl
<< "1. Profit per Metric" <<std::endl
<< "2. Count Sales of type X in a Region" <<std::endl
<< "3. Most popular item type in country X" <<std::endl
<< "4. Online vs Offline Sales in country X" <<std::endl
<< "======" <<std::endl
<< "0 to Exit" <<std::endl;
int choice = AcceptIntInputInRange(0,4);
return choice;
}
std::string ShowPromptAndGetString(std::string prompt) {
std::cout << prompt <<std::endl;
prompt = "";
std::cin >> prompt;
return prompt;
}
void MainInteraction() {
*currentMenu = ShowMainMenu();
switch (*currentMenu) {
case 0:
return;
case 1:
*selectedMetric = ShowPromptAndGetString("Enter The Metric to get total Profit for"); break;
case 2:
*selectedMetric = ShowPromptAndGetString("Enter The item type to search for");
*selectedRegion = ShowPromptAndGetString("Enter The region to search in");
break;
case 3:
*selectedRegion = ShowPromptAndGetString("Enter The country to get most common type for");
break;
case 4:
*selectedRegion = ShowPromptAndGetString("Select Country to count online vs offline purchases");
break;
default:
std::cout << "You should not be able to reach this point if you entered a legal number";
}
}
};
#endif //MENUMANAGER_H

62
Aufg8/ProductSale.cpp Normal file
View File

@@ -0,0 +1,62 @@
//
// Created by DH10MBO on 21.11.2024.
//
#include "ProductSale.h"
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include "../Aufg4/CrimeStats.h"
ProductSale::ProductSale(std::string line) {
std::vector<std::string> result;
split(line, ',', result);
for (int i = 0; i < result.size(); i++) {
switch (i) {
case 0: region = result[0]; break;
case 1: country = result[1]; break;
case 2: itemType = result[2]; break;
case 3: salesChannel = result[3]; break;
case 4: orderPriority = result[4]; break;
case 5: orderDate = result[5]; break;
case 6: orderId = result[6]; break;
case 7: shipDate = result[7]; break;
case 8: unitsSold = round(std::stoi(result[8])*100)/100; break;
case 9: unitPrice = round(std::stod(result[9])*100)/100; break;
case 10:unitCost = round(std::stod(result[10])*100)/100; break;
case 11:totalRevenue = round(std::stod(result[11])*100)/100; break;
case 12:totalCost = round(std::stod(result[12])*100)/100; break;
case 13:totalProfit = round(std::stod(result[13])*100)/100; break;
default:
std::cout << "I should not be able to reach, the line probably contains to many items" << std::endl;
std::cout << line << std::endl;
std::cout << "=========================" << std::endl << result[i] << std::endl;
}
}
}
std::string ProductSale::toString() {
std::ostringstream content;
content
<< "region : " << region << std::endl
<< "country : " << country << std::endl
<< "itemType : " << itemType << std::endl
<< "salesChannel : " << salesChannel << std::endl
<< "orderPriority : " << orderPriority << std::endl
<< "orderDate : " << orderDate << std::endl
<< "orderId : " << orderId << std::endl
<< "shipDate : " << shipDate << std::endl
<< "unitsSold : " << unitsSold << std::endl
<< "unitPrice : " << unitPrice << std::endl
<< "unitCost : " << unitCost << std::endl
<< "totalRevenue : " << totalRevenue << std::endl
<< "totalCost : " << totalCost << std::endl
<< "totalProfit : " << totalProfit;
return content.str();
}

33
Aufg8/ProductSale.h Normal file
View File

@@ -0,0 +1,33 @@
//
// Created by DH10MBO on 21.11.2024.
//
#ifndef PRODUCTSALE_H
#define PRODUCTSALE_H
#include <string>
class ProductSale {
public:
std::string region;
std::string country;
std::string itemType;
std::string salesChannel;
std::string orderPriority;
std::string orderDate;
std::string orderId;
std::string shipDate;
int unitsSold;
double unitPrice;
double unitCost;
double totalRevenue;
double totalCost;
double totalProfit;
ProductSale(std::string line);
std::string toString();
};
#endif //PRODUCTSALE_H

231
Aufg8/SalesStatMain.cpp Normal file
View File

@@ -0,0 +1,231 @@
#include <fstream>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include "MenuManager.h"
#include "ProductSale.h"
#include "../Aufg1/forLoop.h"
std::string readFile(std::string &fileName, std::vector<ProductSale*> &allSales) {
std::string content;
std::ifstream infile;
infile.open(fileName);
if (!infile.is_open()) {
std::cout << "File does not exist" << std::endl;
return "FAILED_TO_READ_FILE";
}
std::string line;
std::getline(infile, line); // Skip first Line
while (std::getline(infile, line)) {
content += line;
ProductSale *temp = new ProductSale(line); // TODO Use Smart Pointers
allSales.push_back(temp);
}
return content;
}
void printAllSales(std::vector<ProductSale*> &allSales) {
for (int i = 0; i < allSales.size(); ++i) {
std::cout << allSales[i]->toString() << std::endl;
std::cout << "==============" << std::endl;
}
}
void deleteAllPointers(std::vector<ProductSale*> &allSales) {
for (auto it = allSales.begin(); it != allSales.end(); it++) {
delete (*it);
}
}
void getTotalProfitFor(std::string metric, std::vector<ProductSale*> &allSales) {
std::map<std::string, long long> TotalPerMetric;
if (metric == "Region") {
for(auto sale : allSales) {
TotalPerMetric[sale->region] += sale->totalProfit;
}
} else if (metric == "Country") {
for(auto sale : allSales) {
TotalPerMetric[sale->country] += sale->totalProfit;
}
} else if (metric=="Item_Type") {
for(auto sale : allSales) {
TotalPerMetric[sale->itemType] += sale->totalProfit;
}
}else if (metric=="Sales_Channel") {
for(auto sale : allSales) {
TotalPerMetric[sale->salesChannel] += sale->totalProfit;
}
}else if (metric == "Order_Priority") {
for(auto sale : allSales) {
TotalPerMetric[sale->orderPriority] += sale->totalProfit;
}
}else if (metric == "Order_Date") {
for(auto sale : allSales) {
TotalPerMetric[sale->orderDate] += sale->totalProfit;
}
}else if (metric == "Order_ID") {
for(auto sale : allSales) {
TotalPerMetric[sale->orderId] += sale->totalProfit;
}
}else if (metric == "Ship_Date") {
for(auto sale : allSales) {
TotalPerMetric[sale->shipDate] += sale->totalProfit;
}
}else if (metric == "Units_Sold") {
for(auto sale : allSales) {
std::string key = std::to_string(sale->unitsSold);
TotalPerMetric[key] += sale->totalProfit;
}
}else if (metric == "Unit_Price") {
for(auto sale : allSales) {
std::string key = std::to_string(sale->unitPrice);
TotalPerMetric[key] += sale->totalProfit;
}
}else if (metric=="Unit_Cost") {
for(auto sale : allSales) {
std::string key = std::to_string(sale->unitCost);
TotalPerMetric[key] += sale->totalProfit;
}
}else if (metric == "Total_Revenue") {
for(auto sale : allSales) {
std::string key = std::to_string(sale->totalRevenue);
TotalPerMetric[key] += sale->totalProfit;
}
}else if (metric == "Total_Cost") {
for(auto sale : allSales) {
std::string key = std::to_string(sale->totalCost);
TotalPerMetric[key] += sale->totalProfit;
}
}else if (metric == "Total_Profit") {
for(auto sale : allSales) {
std::string key = std::to_string(sale->totalProfit);
TotalPerMetric[key] += sale->totalProfit;
}
}else{
std::cout << "Unknown metric :" << metric << std::endl;
return;
}
for (auto entry : TotalPerMetric) {
std::cout << entry.first << " : " << entry.second << std::endl;
}
std::cout << std::endl;
}
void getSaleCount(std::string itemType, std::string country, std::vector<ProductSale*> &allSales) {
long totalSales;
long salesOfTypeX;
for (auto singleSale : allSales) {
if (singleSale->country == country) {
totalSales += singleSale->unitsSold;
if (singleSale->itemType == itemType) {
salesOfTypeX += singleSale->unitsSold;
}
}
}
double ratio = (totalSales == 0) ? 100.0 : static_cast<double>(salesOfTypeX) / totalSales * 50.0;
std::cout << "There were " << totalSales << " total sales in " << country << std::endl;
std::cout << itemType << " were " << salesOfTypeX << " of them in " << country << std::endl;
std::cout << "that's " << ratio << "%" << std::endl << std::endl;
}
void getMostPopularTypeIn(std::string country, std::vector<ProductSale*> &allSales) {
std::map<std::string, int>TypeCounter;
// Filter out wrong countries
for (ProductSale* singleSale : allSales) {
if (singleSale->country != country) {
continue;
}
TypeCounter[singleSale->itemType]++;
}
// return map.getMostCommon
std::string mostPopularType;
int counter = 0;
for (auto element : TypeCounter) {
if (element.second > counter) {
counter = element.second;
mostPopularType = element.first;
}
}
std::cout << "Most popular Type : " << mostPopularType << std::endl
<< "Occurences : " << counter << std::endl << std::endl;
}
void getOnlineVsOfflineIn(std::string country, std::vector<ProductSale*> &allSales) {
std::map<std::string, int>TypeCounter;
for (ProductSale* singleSale : allSales) {
if (singleSale->country != country) {
continue;
}
// Increment the counter for the sales channel directly
TypeCounter[singleSale->salesChannel]++;
}
int OnlineCounter = TypeCounter["Online"];
int OfflineCounter = TypeCounter["Offline"];
double ratio = (OfflineCounter == 0) ? 100.0 : static_cast<double>(OnlineCounter) / OfflineCounter * 50.0;
std::cout << "Online : " << OnlineCounter << std::endl << "Offline : " << OfflineCounter << std::endl;
std::cout << "Ratio : " << ratio << "% Online" << std::endl << std::endl;
}
void Aufg8Main() {
std::vector<ProductSale*> allSales;
std::string fileName = "../Aufg8/IO-Files/sales_records_small.csv";
fileName = "../Aufg8/IO-Files/DANGER-1500000SalesRecords.csv";
link : //https://github.com/HopfTorsten/dhbw-cpp-journey/blob/master/day5/DANGER-1500000SalesRecords.csv.zip
readFile(fileName, allSales);
// printAllSales(allSales);
std::string selectedRegion;
std::string selectedType;
int currentMenu = 0;
std::string* PselectedRegion = &selectedRegion;
std::string* PselectedType = &selectedType;
int* PcurrentMenu = &currentMenu;
MenuManager menu{PcurrentMenu, PselectedType, PselectedRegion};
menu.MainInteraction();
while (currentMenu) {
switch (currentMenu) {
case 0:
return; // To quit the programm
case 1:
getTotalProfitFor(selectedType, allSales);
break;
case 2:
getSaleCount(selectedType, selectedRegion, allSales);
break;
case 3:
getMostPopularTypeIn(selectedRegion, allSales);
break;
case 4:
getOnlineVsOfflineIn(selectedRegion, allSales);
break;
default:
std::cout << "You should not be able to reach this!";
}
menu.MainInteraction();
}
}

10
Aufg8/SalesStatMain.h Normal file
View File

@@ -0,0 +1,10 @@
//
// Created by DH10MBO on 21.11.2024.
//
#ifndef SALESSTATMAIN_H
#define SALESSTATMAIN_H
void Aufg8Main();
#endif //SALESSTATMAIN_H

View File

@@ -0,0 +1,50 @@
#include <fstream>
#include <iostream>
template <typename typ1>
typ1 readFromStream(std::ifstream &stream, char *dest) {
if (stream.is_open()) {
stream.read(dest, sizeof(char[1024]));
typ1 *ptr = reinterpret_cast<typ1 *>(dest);
return std::move(*ptr);
}
else {
std::runtime_error("Could not read from File!");
}
}
void Aufg9Main() {
char *dest = new char[1024];
try {
std::string fileName = "../Aufg9/IO-Files/charakter.d2s";
std::ifstream stream(fileName);
readFromStream<long>(stream, dest);
// Name
char *byte20 = &dest[20];
std::cout << "Name: ";
for (int i = 0; i < 16; i++) {
// std::cout << byte20[i];
std::cout << dest[20 + i];
}
std::cout << std::endl;
// Status
char* byte36 = &dest[36];
std::cout << "Status: " << (((int)(*byte36))%8)/4 << std::endl; // geh zu Byte 36, lies genau 1 byte, interpretiere es als int, berechne mod 8 -> wegwerfen der linken Bits, /4 -> wegwerfen der rechten beiden Bits -> Tada, nur das 3. Bit von Rechts bleibt übrig
// 0 -> Player is not HardCore?
// Klasse
bool *byte40 = (bool*) &dest[40];
std::cout << "Klasse: " << byte40[0] << std::endl;
// 2 -> Necromancer
// Level
bool *byte43 = (bool*) &dest[43];
std::cout << "Level: " << byte43[0] << std::endl;
} catch (const std::exception &e) {
std::cout << e.what() << std::endl;
}
}

11
Aufg9/DiabloByteReader.h Normal file
View File

@@ -0,0 +1,11 @@
//
// Created by DH10MBO on 11.12.2024.
//
#ifndef DIABLOBYTEREADER_H
#define DIABLOBYTEREADER_H
void Aufg9Main();
#endif //DIABLOBYTEREADER_H

View File

@@ -1,31 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35303.130
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CppMainRepo", "CppMainRepo.vcxproj", "{F2E7B59A-E5CA-4180-BE9A-0FF21A5F8048}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F2E7B59A-E5CA-4180-BE9A-0FF21A5F8048}.Debug|x64.ActiveCfg = Debug|x64
{F2E7B59A-E5CA-4180-BE9A-0FF21A5F8048}.Debug|x64.Build.0 = Debug|x64
{F2E7B59A-E5CA-4180-BE9A-0FF21A5F8048}.Debug|x86.ActiveCfg = Debug|Win32
{F2E7B59A-E5CA-4180-BE9A-0FF21A5F8048}.Debug|x86.Build.0 = Debug|Win32
{F2E7B59A-E5CA-4180-BE9A-0FF21A5F8048}.Release|x64.ActiveCfg = Release|x64
{F2E7B59A-E5CA-4180-BE9A-0FF21A5F8048}.Release|x64.Build.0 = Release|x64
{F2E7B59A-E5CA-4180-BE9A-0FF21A5F8048}.Release|x86.ActiveCfg = Release|Win32
{F2E7B59A-E5CA-4180-BE9A-0FF21A5F8048}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6D1082A8-9820-4E91-9CAD-A2C298BDCE1F}
EndGlobalSection
EndGlobal

View File

@@ -1,138 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{f2e7b59a-e5ca-4180-be9a-0ff21a5f8048}</ProjectGuid>
<RootNamespace>CppMainRepo</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="CppMainRepo.cpp" />
</ItemGroup>
<ItemGroup>
<None Include=".gitignore" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Quelldateien">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Headerdateien">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Ressourcendateien">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CppMainRepo.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include=".gitignore" />
</ItemGroup>
</Project>

View File

@@ -1,5 +1,12 @@
# 🧠Brilliantes🧠Repository🧠
## Vorhandene Aufgaben
- VL 1 Aufgabe 1 (Basic Output 10-1 & Alphabet)
- VL 2 Aufgabe 1 (GästeListe mit Konsole In-/Output)
- Aufgabe 1 (Basic Output 10-1 & Alphabet) 👶🍼
- Aufgabe 2 (GästeListe mit Konsole In-/Output) 👀
- Aufgabe 3 (Telefonbuch mit Speichern in Datei) ☎️
- Aufgabe 4 (Auswertung großer Verbrecher-CSV) 🕵️‍♂️
- Aufgabe 5 (Mastermind Code-Guessing-Game) 👺
- Aufgabe 6 (Minesweeper Board Generator) 💣
- Aufgabe 7 (SEGV. und Signal-Handling) 🤖
- Aufgabe 8 (Auswertung riesiger Sales-Datei) 🍇
- Aufgabe 9 (Lesen binärer Speicherdatei) 😵‍💫 (Riesen-Pfusch)🚨