Compare commits

..

7 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
5 changed files with 68 additions and 3 deletions

View File

@@ -9,6 +9,7 @@
#include "Aufg6/MineSweeper.h"
#include "Aufg7/SegFault.h"
#include "Aufg8/SalesStatMain.h"
#include "Aufg9/DiabloByteReader.h"
int main() {
// Aufg1Main();
@@ -18,5 +19,6 @@ int main() {
// Aufg5Main();
// Aufg6Main();
// Aufg7Main();
Aufg8Main();
// Aufg8Main();
Aufg9Main();
}

View File

@@ -191,6 +191,7 @@ 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);
@@ -207,7 +208,7 @@ void Aufg8Main() {
MenuManager menu{PcurrentMenu, PselectedType, PselectedRegion};
menu.MainInteraction();
while (currentMenu) {
switch (currentMenu) { // TODO Finish these
switch (currentMenu) {
case 0:
return; // To quit the programm
case 1:

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

@@ -9,3 +9,4 @@
- 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)🚨