Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Felix Huther
Programmieren2
Commits
48e56c9f
Commit
48e56c9f
authored
Apr 24, 2022
by
Felix Huther
Browse files
const correctness and passing by reference to save storage
parent
6bf23165
Changes
9
Hide whitespace changes
Inline
Side-by-side
HoersaalUebungen/22.02.2022_Sports/Sports/athlete.cpp
View file @
48e56c9f
#include
"athlete.h"
Athlete
::
Athlete
(
FullName
fullName
)
Athlete
::
Athlete
(
FullName
&
fullName
)
:
fullName
(
fullName
)
{
}
void
Athlete
::
printName
()
void
Athlete
::
printName
()
const
{
std
::
cout
<<
fullName
;
...
...
HoersaalUebungen/22.02.2022_Sports/Sports/athlete.h
View file @
48e56c9f
...
...
@@ -6,8 +6,8 @@
class
Athlete
{
public:
explicit
Athlete
(
FullName
fullName
);
virtual
void
printName
();
explicit
Athlete
(
FullName
&
fullName
);
virtual
void
printName
()
const
;
protected:
FullName
fullName
;
...
...
HoersaalUebungen/22.02.2022_Sports/Sports/athletecollection.cpp
View file @
48e56c9f
#include
"athletecollection.h"
#include
<string>
AthleteCollection
::
AthleteCollection
()
{
...
...
@@ -6,25 +7,37 @@ AthleteCollection::AthleteCollection()
void
AthleteCollection
::
addTestData
()
{
//TEST DATA FOOTBALLPLAYER
for
(
int
i
=
0
;
i
<
5
;
i
++
){
std
::
string
firstName
=
"FbpFn"
;
std
::
string
lastName
=
"FbpLn"
;
std
::
string
position
=
"FbpP"
;
Athlete
*
footballPlayer
=
new
FootballPlayer
(
FullName
(
firstName
.
append
(
std
::
to_string
(
i
)),
lastName
.
append
(
std
::
to_string
(
i
))),
position
.
append
(
std
::
to_string
(
i
)));
vecAthletes
.
push_back
(
footballPlayer
);
}
std
::
string
firstName
=
"Philipp"
;
std
::
string
lastName
=
"Lahm"
;
Athlete
*
footballPlayer1
=
new
FootballPlayer
(
FullName
(
firstName
,
lastName
),
"Vorne Links"
)
;
//TEST DATA SWIMMER
for
(
int
i
=
0
;
i
<
5
;
i
++
){
std
::
string
firstName
=
"SwimFn"
;
std
::
string
lastName
=
"SwimLn"
;
std
::
string
style
=
"SwimStyle"
;
Athlete
*
footballPlayer2
=
new
FootballPlayer
(
FullName
(
"Oliver"
,
"Kahn"
),
"Torwart"
);
Athlete
*
footballPlayer3
=
new
FootballPlayer
(
FullName
(
"Sebastian"
,
"Schweinsteiger"
),
"Vorne Rechts"
);
Athlete
*
swimmer1
=
new
Swimmer
(
FullName
(
"Evgeny"
,
"Rylov"
),
"chest"
);
Athlete
*
swimmer2
=
new
Swimmer
(
FullName
(
"Kliment"
,
"KOLESNIKOV"
),
"back"
);
Athlete
*
swimmer3
=
new
Swimmer
(
FullName
(
"Ryan"
,
"MURPHY"
),
"chest"
);
Athlete
*
Swimmer
=
new
FootballPlayer
(
FullName
(
firstName
.
append
(
std
::
to_string
(
i
)),
lastName
.
append
(
std
::
to_string
(
i
))),
style
.
append
(
std
::
to_string
(
i
)));
vecAthletes
.
push_back
(
Swimmer
);
}
addFootballballPlayer
(
footballPlayer1
);
addFootballballPlayer
(
footballPlayer2
);
addFootballballPlayer
(
footballPlayer3
);
addSwimmer
(
swimmer1
);
addSwimmer
(
swimmer2
);
addSwimmer
(
swimmer3
);
// Athlete* footballPlayer2 = new FootballPlayer(FullName("Oliver","Kahn"),"Torwart");
// Athlete* footballPlayer3 = new FootballPlayer(FullName("Sebastian","Schweinsteiger"),"Vorne Rechts");
// Athlete* swimmer1 = new Swimmer(FullName("Evgeny","Rylov"),"chest");
// Athlete* swimmer2 = new Swimmer(FullName("Kliment", "KOLESNIKOV"),"back");
// Athlete* swimmer3 = new Swimmer(FullName("Ryan", "MURPHY"),"chest");
// addFootballballPlayer(footballPlayer2);
// addFootballballPlayer(footballPlayer3);
// addSwimmer(swimmer1);
// addSwimmer(swimmer2);
// addSwimmer(swimmer3);
}
void
AthleteCollection
::
addSwimmer
(
Athlete
*
athlete
)
...
...
HoersaalUebungen/22.02.2022_Sports/Sports/footballplayer.cpp
View file @
48e56c9f
#include
"footballplayer.h"
FootballPlayer
::
FootballPlayer
(
FullName
fullName
,
std
::
string
position
)
FootballPlayer
::
FootballPlayer
(
FullName
fullName
,
std
::
string
&
position
)
:
Athlete
(
fullName
),
position
(
position
)
{
}
void
FootballPlayer
::
printName
()
void
FootballPlayer
::
printName
()
const
{
Athlete
::
printName
();
std
::
cout
<<
" Position: "
<<
position
;
...
...
HoersaalUebungen/22.02.2022_Sports/Sports/footballplayer.h
View file @
48e56c9f
...
...
@@ -5,8 +5,8 @@
class
FootballPlayer
:
public
Athlete
{
public:
FootballPlayer
(
FullName
fullName
,
std
::
string
position
);
void
printName
()
override
;
FootballPlayer
(
FullName
fullName
,
std
::
string
&
position
);
void
printName
()
const
;
private:
std
::
string
position
;
...
...
HoersaalUebungen/22.02.2022_Sports/Sports/fullname.cpp
View file @
48e56c9f
#include
"fullname.h"
FullName
::
FullName
(
std
::
string
firstName
,
std
::
string
lastName
)
FullName
::
FullName
(
std
::
string
&
firstName
,
std
::
string
&
lastName
)
:
firstName
(
firstName
),
lastName
(
lastName
)
{
...
...
HoersaalUebungen/22.02.2022_Sports/Sports/fullname.h
View file @
48e56c9f
...
...
@@ -5,7 +5,7 @@
class
FullName
{
public:
FullName
(
std
::
string
firstName
,
std
::
string
lastName
);
FullName
(
std
::
string
&
firstName
,
std
::
string
&
lastName
);
const
std
::
string
&
getFirstName
()
const
;
...
...
HoersaalUebungen/22.02.2022_Sports/Sports/swimmer.cpp
View file @
48e56c9f
#include
"swimmer.h"
Swimmer
::
Swimmer
(
FullName
fullName
,
std
::
string
stil
)
Swimmer
::
Swimmer
(
FullName
fullName
,
std
::
string
&
stil
)
:
Athlete
(
fullName
),
stil
(
stil
)
{
}
void
Swimmer
::
printName
()
void
Swimmer
::
printName
()
const
{
Athlete
::
printName
();
std
::
cout
<<
" Stil: "
<<
stil
;
...
...
HoersaalUebungen/22.02.2022_Sports/Sports/swimmer.h
View file @
48e56c9f
...
...
@@ -5,8 +5,8 @@
class
Swimmer
:
public
Athlete
{
public:
Swimmer
(
FullName
fullName
,
std
::
string
style
);
void
printName
()
override
;
Swimmer
(
FullName
fullName
,
std
::
string
&
style
);
void
printName
()
const
;
private:
std
::
string
stil
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment