Commit 044c72b2 authored by Felix Huther's avatar Felix Huther
Browse files

some coding

parent 9022e83c
......@@ -8,6 +8,8 @@ SOURCES += \
consoleui.cpp \
fussballer.cpp \
main.cpp \
profifussballer.cpp \
profisportler.cpp \
schwimmer.cpp \
sportler.cpp \
sportverein.cpp \
......@@ -17,6 +19,8 @@ HEADERS += \
abstractui.h \
consoleui.h \
fussballer.h \
profifussballer.h \
profisportler.h \
schwimmer.h \
sportler.h \
sportverein.h \
......
......@@ -6,7 +6,13 @@ ConsoleUI::ConsoleUI(const Sportverein &sportverein) : mSportverein(sportverein)
void ConsoleUI::ausgabe() const
{
for(auto sportler : mSportverein.getSportlers())
for(auto sportler: mSportverein.getSportlers())
{
sportler->printState();
std::cout << std::endl;
}
/*for(auto sportler : mSportverein.getSportlers())
{
const VollerName fullname = sportler->getVollerName();
......@@ -15,9 +21,17 @@ void ConsoleUI::ausgabe() const
if(typeid(*sportler) == typeid(Fussballer))
{
Fussballer* pFussballer = static_cast<Fussballer*>(sportler);
//Fussballer* dcpFussballer = dynamic_cast<Fussballer*>(sportler);
Fussballer* pFussballer = reinterpret_cast<Fussballer*>(sportler);
std::cout << pFussballer->getPosition() << std::endl;
}
else if(typeid(*sportler) == typeid(ProfiFussballer))
{
ProfiFussballer* pProfifussballer = reinterpret_cast<ProfiFussballer*>(sportler);
std::cout << pProfifussballer->getPosition() << std::endl;
std::cout << pProfifussballer->gehalt() << std::endl;
}
else if(typeid(*sportler) == typeid(Schwimmer))
{
Schwimmer* pSchwimmer = static_cast<Schwimmer*>(sportler);
......@@ -27,6 +41,7 @@ void ConsoleUI::ausgabe() const
std::cout << std::endl;
}
*/
}
......
......@@ -5,15 +5,15 @@
#include "sportverein.h"
#include "fussballer.h"
#include "schwimmer.h"
#include "profifussballer.h"
#include "profisportler.h"
class ConsoleUI : public AbstractUI
{
public:
ConsoleUI(const Sportverein& sportverein);
private:
const Sportverein mSportverein;
......
......@@ -2,10 +2,18 @@
const std::string &Fussballer::getPosition() const
{
return position;
return mPosition;
}
void Fussballer::printState()
{
std::cout << "Position: "<< mPosition << std::endl;
std::cout << "Name : " << mVollerName << std::endl;
}
Fussballer::Fussballer(std::string position, VollerName vollerName) : Sportler(vollerName),
position(position)
Fussballer::Fussballer(std::string position, VollerName vollerName) :
Sportler(vollerName),
mPosition(position)
{}
......@@ -2,7 +2,7 @@
#define FUSSBALLER_H
#include "sportler.h"
class Fussballer : public Sportler
class Fussballer : public virtual Sportler
{
public:
Fussballer(std::string position, VollerName vollerName);
......@@ -10,7 +10,11 @@ public:
const std::string &getPosition() const;
private:
std::string position;
std::string mPosition;
// Sportler interface
public:
void printState() override;
};
#endif // FUSSBALLER_H
#include "profifussballer.h"
ProfiFussballer::ProfiFussballer(std::string gehalt, std::string position, VollerName fullname)
:Sportler(fullname),Fussballer(position,fullname),ProfiSportler(fullname,gehalt)
{
}
void ProfiFussballer::printState()
{
std::cout <<"Name: "<< mVollerName << std::endl;
std::cout <<"Gehalt: " << gehalt() << std::endl;
std::cout <<"Position: " << getPosition() << std::endl;
}
#ifndef PROFIFUSSBALLER_H
#define PROFIFUSSBALLER_H
#include "fussballer.h"
#include "profisportler.h"
class ProfiFussballer : public Fussballer, public ProfiSportler
{
public:
ProfiFussballer(std::string gehalt,std::string position, VollerName fullname);
// Sportler interface
public:
void printState() override;
};
#endif // PROFIFUSSBALLER_H
#include "profisportler.h"
ProfiSportler::ProfiSportler(VollerName fullname, std::string gehalt)
:Sportler(fullname),mGehalt(gehalt)
{
}
const std::string &ProfiSportler::gehalt() const
{
return mGehalt;
}
void ProfiSportler::printState()
{
std::cout << mVollerName << std::endl;
std::cout << mGehalt;
}
#ifndef PROFISPORTLER_H
#define PROFISPORTLER_H
#include "sportler.h"
class ProfiSportler : public virtual Sportler
{
public:
ProfiSportler(VollerName fullname, std::string gehalt);
const std::string &gehalt() const;
private:
std::string mGehalt;
// Sportler interface
public:
void printState() override;
};
#endif // PROFISPORTLER_H
......@@ -6,6 +6,13 @@ const std::string &Schwimmer::getStil() const
return mStil;
}
void Schwimmer::printState()
{
std::cout <<"Name: " << mVollerName << std::endl;
std::cout <<"Stil: " << mStil << std::endl;
}
Schwimmer::Schwimmer( std::string &stil, VollerName &vollerName) : Sportler(vollerName),
mStil(stil)
{}
......@@ -7,12 +7,14 @@ class Schwimmer : public Sportler
public:
Schwimmer( std::string &stil, VollerName &vollerName);
const std::string &getStil() const;
private:
std::string mStil;
// Sportler interface
public:
void printState() override;
};
#endif // SCHWIMMER_H
......@@ -2,9 +2,14 @@
const VollerName &Sportler::getVollerName() const
{
return vollerName;
return mVollerName;
}
void Sportler::printState()
{
}
Sportler::Sportler(VollerName vollerName) : vollerName(vollerName)
Sportler::Sportler(VollerName vollerName) : mVollerName(vollerName)
{}
......@@ -2,6 +2,9 @@
#define SPORTLER_H
#include "vollername.h"
class Schwimmer;
class Fussballer;
class ProfiFussballer;
class Sportler
{
public:
......@@ -9,8 +12,10 @@ public:
const VollerName &getVollerName() const;
virtual void printState();
protected:
VollerName vollerName;
VollerName mVollerName;
};
......
......@@ -31,7 +31,7 @@ void Sportverein::addTestData()
//TEST DATA SWIMMER
for(int i = 0 ; i < 5 ; i++){
for(int i = 0 ; i < 2 ; i++){
VollerName fullname("Jochen","Matterhorn");
std::string stil ="Swimstil";
......@@ -40,4 +40,20 @@ void Sportverein::addTestData()
sportlers.push_back(schwimmer);
}
//TEST DATA PRO FUSSBALLER
for(int i = 0 ; i < 5 ; i++){
std::string gehalt = "100000";
std::string position ="Mitte";
VollerName fullname("Bastian","Schweinsteiger");
Sportler* fussballer = new ProfiFussballer(gehalt,position,fullname);
sportlers.push_back(fussballer);
}
}
......@@ -5,6 +5,7 @@
#include "vollername.h"
#include "fussballer.h"
#include "schwimmer.h"
#include "profifussballer.h"
class Sportverein
{
......
#ifndef VOLLERNAME_H
#define VOLLERNAME_H
#include <string>
#include <ostream>
#include <iostream>
class VollerName
{
......@@ -8,14 +10,20 @@ public:
VollerName();
VollerName(std::string vorname, std::string nachname);
const std::string &getVorname() const;
const std::string &getNachname() const;
friend std::ostream &operator<<(std::ostream& os, const VollerName fullname)
{
os << fullname.vorname << " " << fullname.nachname;
return os;
}
private:
std::string vorname;
std::string nachname;
};
#endif // VOLLERNAME_H
QMAKE_CXX.QT_COMPILER_STDCXX = 201703L
QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 11
QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 2
QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0
QMAKE_CXX.COMPILER_MACROS = \
QT_COMPILER_STDCXX \
QMAKE_GCC_MAJOR_VERSION \
QMAKE_GCC_MINOR_VERSION \
QMAKE_GCC_PATCH_VERSION
QMAKE_CXX.INCDIRS = \
C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++ \
C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/x86_64-w64-mingw32 \
C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/backward \
C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include \
C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include-fixed \
C:/Qt/Tools/mingw1120_64/x86_64-w64-mingw32/include
QMAKE_CXX.LIBDIRS = \
C:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0 \
C:/Qt/Tools/mingw1120_64/lib/gcc \
C:/Qt/Tools/mingw1120_64/x86_64-w64-mingw32/lib \
C:/Qt/Tools/mingw1120_64/lib
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment