Roulett-Problem



  • Hallo,
    ich bin noch ein Anfänger, habe mir ein Roulettspiel geschrieben. Es klappt auch alles so wie es klappen soll aber der Quelltext gefällt mir nicht. Also schreibe ich es neu und da ist das Problem. Nachdem ich den groeßten Teil geschrieben hatte bombadierte mich der Compiler mit Fehlermeldungen und ich weiß nicht was ich falsch gemacht habe. Folgende Fehler traten auf:

    C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp: In member function void roulett::zahl()': 52 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:52: error: invalid use of member (did you forget the&' ?)

    C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp: In member function void roulett::gerade()': 93 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:93: error: invalid use of member (did you forget the&' ?)

    C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp: In member function void roulett::farbe()': 136 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:136: error: invalid use of member (did you forget the&' ?)
    136 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:136: error: invalid use of member (did you forget the &' ?) 136 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:136: error: invalid use of member (did you forget the&' ?)
    136 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:136: error: invalid use of member (did you forget the &' ?) 136 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:136: error: invalid use of member (did you forget the&' ?)
    136 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:136: error: invalid use of member (did you forget the &' ?) 136 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:136: error: invalid use of member (did you forget the&' ?)

    136 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:136: error: invalid use of member (did you forget the &' ?) 136 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:136: error: invalid use of member (did you forget the&' ?)
    136 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:136: error: invalid use of member (did you forget the &' ?) 136 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:136: error: invalid use of member (did you forget the&' ?)
    136 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:136: error: invalid use of member (did you forget the &' ?) 136 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:136: error: invalid use of member (did you forget the&' ?)
    136 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:136: error: invalid use of member (did you forget the &' ?) 136 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:136: error: invalid use of member (did you forget the&' ?)

    136 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:136: error: invalid use of member (did you forget the &' ?) 136 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:136: error: invalid use of member (did you forget the&' ?)

    148 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:148: error: invalid use of member (did you forget the `&' ?)

    148 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:148: error: invalid use of member (did you forget the &' ?) 148 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:148: error: invalid use of member (did you forget the&' ?)
    148 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:148: error: invalid use of member (did you forget the &' ?) 148 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:148: error: invalid use of member (did you forget the&' ?)
    148 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:148: error: invalid use of member (did you forget the &' ?) 148 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:148: error: invalid use of member (did you forget the&' ?)
    148 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:148: error: invalid use of member (did you forget the `&' ?)

    148 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:148: error: invalid use of member (did you forget the &' ?) 148 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:148: error: invalid use of member (did you forget the&' ?)
    148 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:148: error: invalid use of member (did you forget the &' ?) 148 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:148: error: invalid use of member (did you forget the&' ?)
    148 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:148: error: invalid use of member (did you forget the &' ?) 148 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:148: error: invalid use of member (did you forget the&' ?)
    148 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:148: error: invalid use of member (did you forget the &' ?) 148 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:148: error: invalid use of member (did you forget the&' ?)

    148 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:148: error: invalid use of member (did you forget the &' ?) 148 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:148: error: invalid use of member (did you forget the&' ?)
    148 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:148: error: invalid use of member (did you forget the `&' ?)

    C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp: In member function void roulett::reihe()': 192 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:192: error: invalid use of member (did you forget the&' ?)
    192 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:192: error: invalid use of member (did you forget the &' ?) 192 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:192: error: invalid use of member (did you forget the&' ?)
    192 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:192: error: invalid use of member (did you forget the &' ?) 192 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:192: error: invalid use of member (did you forget the&' ?)

    192 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:192: error: invalid use of member (did you forget the &' ?) 192 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:192: error: invalid use of member (did you forget the&' ?)
    192 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:192: error: invalid use of member (did you forget the &' ?) 192 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:192: error: invalid use of member (did you forget the&' ?)
    192 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:192: error: invalid use of member (did you forget the &' ?) 192 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:192: error: invalid use of member (did you forget the&' ?)
    204 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:192: error: invalid use of member (did you forget the &' ?) 204 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:204: error: invalid use of member (did you forget the&' ?)

    204 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:204: error: invalid use of member (did you forget the &' ?) 204 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:204: error: invalid use of member (did you forget the&' ?)
    204 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:204: error: invalid use of member (did you forget the &' ?) 204 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:204: error: invalid use of member (did you forget the&' ?)
    204 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:204: error: invalid use of member (did you forget the &' ?) 204 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:204: error: invalid use of member (did you forget the&' ?)
    204 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:204: error: invalid use of member (did you forget the &' ?) 204 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:204: error: invalid use of member (did you forget the&' ?)

    204 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:204: error: invalid use of member (did you forget the &' ?) 204 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:204: error: invalid use of member (did you forget the&' ?)
    216 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:204: error: invalid use of member (did you forget the &' ?) 216 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:216: error: invalid use of member (did you forget the&' ?)
    216 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:216: error: invalid use of member (did you forget the &' ?) 216 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:216: error: invalid use of member (did you forget the&' ?)
    216 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:216: error: invalid use of member (did you forget the &' ?) 216 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:216: error: invalid use of member (did you forget the&' ?)

    216 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:216: error: invalid use of member (did you forget the &' ?) 216 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:216: error: invalid use of member (did you forget the&' ?)
    216 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:216: error: invalid use of member (did you forget the &' ?) 216 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:216: error: invalid use of member (did you forget the&' ?)
    216 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:216: error: invalid use of member (did you forget the &' ?) 216 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:216: error: invalid use of member (did you forget the&' ?)
    216 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:216: error: invalid use of member (did you forget the &' ?) C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp: In functionint main()':
    273 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:273: error: invalid use of member (did you forget the &' ?) 274 C:\\Dokumente und Einstellungen\\as\\Desktop\\roulettx2.cpp:274: error: invalid use of member (did you forget the&' ?)
    350 C:\Dokumente und Einstellungen\as\Desktop\roulettx2.cpp:350: error: no match for 'operator<<' in 'std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::char_traits<char> >&)(&std::cout)), ((const char*)"\nZahl ist: ")) << spielera.roulett::zahl'
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/bits/ostream.tcc:63: note: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>&()(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/bits/ostream.tcc:74: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ios<_CharT, _Traits>&(
    )(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/bits/ostream.tcc:86: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base&(*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/bits/ostream.tcc:121: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/bits/ostream.tcc:155: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/bits/ostream.tcc:98: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/ostream:178: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/ostream:189: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/ostream:193: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/ostream:204: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/bits/ostream.tcc:179: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/bits/ostream.tcc:214: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]

    note C:/Programme/Dev-Cpp/include/c++/3.4.2/bits/ostream.tcc:238: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/ostream:219: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/bits/ostream.tcc:261: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/bits/ostream.tcc:284: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits<char>]

    note C:/Programme/Dev-Cpp/include/c++/3.4.2/bits/ostream.tcc:307: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_streambuf<_CharT, _Traits>) [with _CharT = char, _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/ostream:449: note: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, char) [with _CharT = char, _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/bits/ostream.tcc:505: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char) [with _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/ostream:460: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, signed char) [with _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/ostream:465: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, unsigned char) [with _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/bits/ostream.tcc:567: note: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char
    ) [with _CharT = char, _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/bits/ostream.tcc:612: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char*) [with _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/ostream:499: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const signed char*) [with _Traits = std::char_traits<char>]
    note C:/Programme/Dev-Cpp/include/c++/3.4.2/ostream:504: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const unsigned char*) [with _Traits = std::char_traits<char>]

    Ich weis absolut nicht was mit (did you forget the `&' ?) gemeint ist.
    Bitte helft mir hier ist derr Quellcode zum Programm:

    #include <iostream>
    #include <fstream>
    #include <cstdio>
    using namespace std;
    
    /*  Lehren des Bildschirms mit Struktur erzwingen   */
    struct leer
    {
           char* leer;
    }my_leer={"CLS"};
    
    /*   Klasse Roulett   */
    class roulett
    {
          public:
                 int geld, einsatz, tipp, game ;
                 char name[25] ;
                 fstream score;
                 string hscore ;
    
                 void zahl();
                 void gerade();
                 void farbe();
                 void reihe();
                 void save();
    };
    
    /*   Tipp auf Zahl   */
    void roulett::zahl(void)
    {
         try
         {
    
         cout << "\nBitte tippen sie auf eine Zahl:  " ;
         cin >> tipp ;
    
         cout << "\nIhr Einsatz:  " ;
         cin >> einsatz ;
    
         if( tipp < 0 || tipp > 36 )
         {
             cout << "\nSie duerfen nur Zahlen zwischen 0 und 36 eingeben\n" ;
             throw "Fehleingabe";
         }
    
         if( einsatz > geld )
         {
             cout << "Ihr Einsatz ist groesser als ihr Guthaben !\n" ;
             throw "Fehleingabe";
         }
    
         if( tipp == zahl )
         {
             geld += einsatz * 35 ;
         }
         else
         {
             geld -= einsatz ;
         }
    
         }
         catch(const char*)
         {
         cin.clear();
         zahl();
         }
    }
    
    /*   Tipp auf gerade   */
    void roulett::gerade(void)
    {
         try
         {
    
         cout << "\n1 fuer ungerade zahl, 2 fuer gerade Zahl:  " ;
         cin >> tipp ;
    
         if( tipp != 1 && tipp != 2 )
         {
             cout << "\nSie duerfen nur die Zahlen 1 oder 2 eingeben!\n" ;
             throw "Fehleingabe";
         }
    
         cout << "Ihr Einsatz:  " ;
         cin >> einsatz ;
    
         if( einsatz > geld )
         {
             cout << "Ihr Einsatz ist groesser als ihr Guthaben !\n" ;
             throw "Fehleingabe";
         }
    
         if( tipp % 2 == zahl % 2 ) 
         {
             geld += einsatz ;
         }
         else
         {
             geld -= einsatz ;
         }
    
         }
         catch(const char*)
         {
         cin.clear();
         gerade();
         }
    }
    
    /*   Tipp auf Farbe   */
    void roulett::farbe(void)
    {
         try
         {
    
         cout << "\nAuf welche Farbe wollen sie setzen?\nBitte geben sie 1 (fuer rot) oder 2 (fuer schwarz) ein:  ";
         cin >> tipp ;
    
         if( tipp != 1 && tipp != 2 )
         {
             cout << "Falsche Eingabe: Sie duerfen nur 1 (fuer rot)oder 2 (fuer schwarz) eingeben !" ;
             throw "Fehleingabe";
         }
    
         cout << "Ihr Einsatz:  " ;
         cin >> einsatz ;
    
         if( einsatz > geld )
         {
             cout << "Ihr Einsatz ist groesser als ihr Guthaben !\n" ;
             throw "Fehleingabe";
         }
    
         if( tipp == 1 )
         {
             if( zahl ==  1 || zahl == 3 || zahl == 5 || zahl == 7 || zahl == 9 || zahl == 12 || zahl == 14 || zahl == 16 || zahl == 19 ||zahl == 21 || zahl == 23 || zahl == 25 || zahl == 27 || zahl == 30 || zahl == 32 || zahl == 34  || zahl == 36 )
             {
                 geld += einsatz ;
             }
             else
             {
                 geld -= einsatz ;
             }
         }
    
         if( tipp == 2 )
         {
             if( zahl == 2 || zahl == 4 || zahl == 6 || zahl == 8 || zahl == 10 || zahl == 11 || zahl == 13 || zahl == 15 || zahl == 17 || zahl == 18 || zahl == 20 || zahl == 22 || zahl == 24 || zahl == 26 || zahl == 28 || zahl == 29 || zahl == 31 || zahl == 33 || zahl == 35 )
             {
                 geld += einsatz ;
             }
             else
             {
                 geld -= einsatz ;
             }
         }
    
         }
         catch(const char*)
         {
         cin.clear();
         farbe(); 
         }
    
    }
    
    /*   Tipp auf Reihe   */
    void roulett::reihe(void)
    {
         try
         {
             cout << "Bitte tippen sie auf eine Reihe (von 1 bis 3)\n" ;
             cin >> tipp ;
    
             if( tipp < 1 || tipp > 3 )
             {
                 cout << "\nEs gibt nur 3 Reihen !!!\n" ;
                 throw "Fehleingabe" ;
             }
    
             cout << "Ihr Einsatz:  " ;
             cin >> einsatz ;
    
             if( einsatz > geld )
             {
                 cout << "Ihr Einsatz ist groesser als ihr Guthaben !\n" ;
                 throw "Fehleingabe";
             }
    
             if( tipp == 1 )
             {
                 if( zahl == 1 || zahl == 4 || zahl == 7 || zahl == 10 || zahl == 13 || zahl == 16 || zahl == 19 || zahl == 22 || zahl == 25 || zahl == 28 || zahl == 31 || zahl == 34 )
                 {
                     geld += einsatz ;
                 }
                 else
                 {
                     geld -= einsatz ;
                 }
             }
    
             if( tipp == 2 )
             {
                 if( zahl == 2 || zahl == 5 || zahl == 8 || zahl == 11 || zahl == 14 || zahl == 17 || zahl == 20 || zahl == 23 || zahl == 26 || zahl == 29 || zahl == 32 || zahl == 35 )
                 {
                     geld += einsatz ;
                 }
                 else
                 {
                     geld -= einsatz ;
                 }
             }
    
             if( tipp == 3 )
             {
                 if( zahl == 3 || zahl == 6 || zahl == 9 || zahl == 12 || zahl == 15 || zahl == 18 || zahl == 21 || zahl == 24 || zahl == 27 || zahl == 30 || zahl == 33 || zahl == 36 )
                 {
                     geld += einsatz ;
                 }
                 else
                 {
                     geld -= einsatz ;
                 }
             }
    
         }
         catch(const char*)
         {
         cin.clear();
         reihe(); 
         }
    }
    
    /*   Speichern   */
    void roulett::save(void)
    {
         cout << "Dein Name: ";
         cin >> name;
    
         score.open("c:\\Roulettscore.sc", ios::binary | ios::out | ios::app);
         score << name << ":" << geld << "/";
         score.close();
    
         system(my_leer.leer);
    
         cout << "\n\n\n\tRoulett 2 Multiplayer\n\n\t(C) 2006 Norman Hansen\n\n" ;
    
         system("PAUSE");
         system(my_leer.leer);
    
         game = 0 ;
    }
    
    /*   Hauptprogramm   */
    int main()
    {
        int x, n ;
        char wahl;
        roulett spielera, spielerb ;
    
        /*   Startparameter festlegen   */
        srand((unsigned) time(NULL));
    
        spielera.geld = 50 ;
        spielerb.geld = 50 ;
    
        cout << "\nJede Eingabe muss mit Enter bestaetigt werden !" ;
    
        for(;;)
        {
    
           /*   Zahl generieren    */
           spielera.zahl = rand() % 37 ;
           spielerb.zahl = spielera.zahl ;
    
           /*   Nur zum Testen     */
           //cout << "\n" << spielera.zahl << \n ;
    
           cout << "Spieler 1\n\n" ;
           cout << "\nWie oft wollen sie setzen?   " ;
           cin >> x ;
    
           for( n = 0 ; n < x ; n++ )
           {
                     cout << "<z> auf Zahl tippen\n<g> auf gerade oder ungrade Zahl tippen\n"
                          << "<r> auf eine verikale Reihe tippen\n<f> auf Farbe tippen\n" ;
                     cin >> wahl ;
    
                     if( wahl != 'z' && wahl != 'Z' && wahl != 'g' && wahl != 'G' && wahl != 'r' && wahl != 'R' && wahl != 'f' && wahl != 'F' && wahl != 'c' && wahl != 'C' && wahl != 's' && wahl != 'S')
                     {
                         cout << "\nFalsche Eingabe !!!\n\n" ;
                         n-- ;
                     }
    
                     switch(wahl){
                                  case 'z' : spielera.zahl() ;
                                  case 'g' : spielera.gerade() ;
                                  case 'r' : spielera.reihe() ;
                                  case 'f' : spielera.farbe() ;
                                  case 's' : spielera.save() ;
                                 }
           }
           /*   Bildschirm leeren   */
           system(my_leer.leer);
    
           cout << "Spieler 2\n\n" ;
           cout << "\nWie oft wollen sie setzen?   " ;
           cin >> x ;
    
           for( n = 0 ; n < x ; n++ )
           {
                     cout << "<z> auf Zahl tippen\n<g> auf gerade oder ungrade Zahl tippen\n"
                          << "<r> auf eine verikale Reihe tippen\n<f> auf Farbe tippen\n" ;
                     cin >> wahl ;
    
                     if( wahl != 'z' && wahl != 'Z' && wahl != 'g' && wahl != 'G' && wahl != 'r' && wahl != 'R' && wahl != 'f' && wahl != 'F' && wahl != 'c' && wahl != 'C' && wahl != 's' && wahl != 'S')
                     {
                         cout << "\nFalsche Eingabe !!!\n\n" ;
                         n-- ;
                     }
    
                     switch(wahl){
                                  case 'z' : spielerb.zahl() ;
                                  case 'g' : spielerb.gerade() ;
                                  case 'r' : spielerb.reihe() ;
                                  case 'f' : spielerb.farbe() ;
                                  case 's' : spielerb.save() ;
                                 }
    
           if( spielera.geld < 1 ) break ;
           if( spielerb.geld < 1 ) break ;
    
           }
           /*   Bildschirm leeren   */
           system(my_leer.leer);
    
           if( spielera.geld < 1 )
           {
               cout << "\nSpieler 1 sie haben verloren !!\n\nGewinner ist Spieler 2 !\n\n" ;
               spielera.game = 0 ;
           }
    
           if( spielerb.geld < 1 )
           {
               cout << "\nSpieler 2 sie haben verloren !!\n\nGewinner ist Spieler 1 !\n\n" ;
               spielerb.game = 0 ;
           }
    
            cout << "\nZahl ist: " << spielera.zahl << "\n" ;
            cout << "Guthaben Spieler 1 : " << spielera.geld << "\n" ;
            cout << "Guthaben Spieler 2 : " << spielerb.geld << "\n\n" ;
    
           if( spielera.game == 0 || spielerb.game == 0 ) break ;
    
    }
    return 0 ;
    }
    


  • hab nicht viel zeit, deshalb nur zur optimierung:

    zahl == 1 || zahl == 4 || zahl == 7 || zahl == 10 || zahl == 13 || zahl == 16 || zahl == 19 || zahl == 22 || zahl == 25 || zahl == 28 || zahl == 31 || zahl == 34
    

    ist nix anderes als "zahl mod 3 == 1"
    das kann man dann umsetzen:

    if( fmod (zahl, 3) == 1 ) usw.
    

    [EDIT:] und vergiss nicht <math.h> einzubinden!

    tschüss
    chris90



  • Hab' mir mal die Mühe gemacht, Zeile 52 auszuzählen (weil dort der erste Fehler auftritt):

    if(tipp==zahl)
    

    'zahl' ist keine Variable, sondern eine Memberfunktion - du benötigst noch eine Methode, mit der du wirklich die Kugel rollen lässt.



  • In roulett::zahl() passiert folgendes:

    if( tipp == zahl )
    

    Warum vergleichst Du ein Integer (tipp) mit einer Methode (zahl) ? 😉



  • Danke ich werds versuchen und wenn es nicht klappt poste ichs neu


Anmelden zum Antworten