Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
magicCards
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Thomas Letzgus
magicCards
Commits
6e97f8d0
Commit
6e97f8d0
authored
2 years ago
by
Eraser
Browse files
Options
Downloads
Patches
Plain Diff
Aufgabe 3 done
parent
228fc247
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
CMakeLists.txt
+1
-1
1 addition, 1 deletion
CMakeLists.txt
Cards.h
+2
-1
2 additions, 1 deletion
Cards.h
functions.cpp
+67
-0
67 additions, 0 deletions
functions.cpp
functions.h
+14
-0
14 additions, 0 deletions
functions.h
main.cpp
+5
-0
5 additions, 0 deletions
main.cpp
with
89 additions
and
2 deletions
CMakeLists.txt
+
1
−
1
View file @
6e97f8d0
...
@@ -3,4 +3,4 @@ project(magicCards)
...
@@ -3,4 +3,4 @@ project(magicCards)
set
(
CMAKE_CXX_STANDARD 20
)
set
(
CMAKE_CXX_STANDARD 20
)
add_executable
(
magicCards main.cpp aufgabe1.h aufgabe1.cpp Cards.h
)
add_executable
(
magicCards main.cpp aufgabe1.h aufgabe1.cpp Cards.h
functions.h functions.cpp
)
This diff is collapsed.
Click to expand it.
Cards.h
+
2
−
1
View file @
6e97f8d0
...
@@ -8,10 +8,11 @@
...
@@ -8,10 +8,11 @@
//Aufgabe Nr.2
//Aufgabe Nr.2
struct
Cards
{
struct
Cards
{
//cmc and count are also strings to make it easier for the getListOfCards function
public:
public:
std
::
string
name
;
std
::
string
name
;
std
::
string
mana
;
std
::
string
mana
;
in
t
cmc
;
std
::
str
in
g
cmc
;
std
::
string
type
;
std
::
string
type
;
std
::
string
count
;
std
::
string
count
;
...
...
This diff is collapsed.
Click to expand it.
functions.cpp
0 → 100644
+
67
−
0
View file @
6e97f8d0
//
// Created by Eray düzenli on 13.04.23.
//
#include
<iostream>
#include
"functions.h"
#include
<fstream>
#include
<stdexcept>
#include
<sstream>
#include
<vector>
//std::list<Cards> getListOfCards(const std::string& filename)
std
::
list
<
Cards
>
getListOfCards
(
const
std
::
string
&
filename
)
{
std
::
ifstream
file
(
filename
);
if
(
!
file
)
{
throw
std
::
runtime_error
(
"Error: Unable to open file "
+
filename
);
}
//temp string to save line
std
::
string
temp
;
//Output
std
::
list
<
Cards
>
CardsList
;
//get every line of scrambled.txt
while
(
std
::
getline
(
file
,
temp
))
{
std
::
stringstream
streamData
(
temp
);
//"cut" the string at the vertical bars(|)
char
delim
=
'|'
;
//string vector to hold the cut parts
std
::
vector
<
std
::
string
>
stringVector
;
//temp to store Card attributes
std
::
string
attr
;
//go over every line, cut line accordingly and push it at the back of the vector
while
(
getline
(
streamData
,
attr
,
delim
))
{
stringVector
.
push_back
(
attr
);
}
//assign every cut out part to the according attribute
std
::
string
name
=
stringVector
[
0
];
std
::
string
mana
=
stringVector
[
1
];
std
::
string
cmc
=
stringVector
[
2
];
std
::
string
type
=
stringVector
[
3
];
std
::
string
count
=
stringVector
[
4
];
//create card object and assign attributes to it
Cards
card
;
card
.
cmc
=
cmc
;
card
.
mana
=
mana
;
card
.
name
=
name
;
card
.
type
=
type
;
card
.
count
=
count
;
//push Card object at the end of the List
CardsList
.
push_back
(
card
);
}
//close .txt file
file
.
close
();
/* just for testing
for (const auto& card : CardsList) {
std::cout << card.name << ", " << card.mana << ", " << card.cmc << ", " << card.type << ", " << card.count << std::endl;
}
*/
//return the cards as a list
return
CardsList
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
functions.h
0 → 100644
+
14
−
0
View file @
6e97f8d0
//
// Created by Eray düzenli on 13.04.23.
//
#pragma once
#include
<string>
#include
<iostream>
#include
<list>
#include
"Cards.h"
std
::
list
<
Cards
>
getListOfCards
(
const
std
::
string
&
filename
);
This diff is collapsed.
Click to expand it.
main.cpp
+
5
−
0
View file @
6e97f8d0
#include
<iostream>
#include
<iostream>
#include
"aufgabe1.h"
#include
"aufgabe1.h"
#include
"Cards.h"
#include
"Cards.h"
#include
"functions.h"
int
main
()
{
int
main
()
{
/*
std::cout << "Info 3 Projekt Nr.1" << std::endl;
std::cout << "Info 3 Projekt Nr.1" << std::endl;
levenshteinDistance("kitten", "sitting");
levenshteinDistance("kitten", "sitting");
levenshteinDistance("industry", "interests");
levenshteinDistance("industry", "interests");
...
@@ -16,6 +18,9 @@ int main() {
...
@@ -16,6 +18,9 @@ int main() {
s.name = "peter";
s.name = "peter";
s.type = "uwu";
s.type = "uwu";
std::cout << s.name << s.count << s.type << s.cmc << std::endl;
std::cout << s.name << s.count << s.type << s.cmc << std::endl;
//To-Do, only absolute path works
*/
getListOfCards
(
"/Users/erayduzenli/CLionProjects/magicCards/scrambled.txt"
);
return
0
;
return
0
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment