Simple pet caring game - console I'm a beginner programmer and i'm looking for interesting projects to improve my low skills. I tried one day to improve my skills by trying to create a small game in which a user owns a cat, and has to feed it and clean it. My main aim of the game(which yet has many illogical things like the never decreasing happiness and cleanness level) was to try and keep my code as clean and presentable as possible. The game is made in 4 different files, and I will paste them all below. I will be happy if anyone could give me help on understanding where should I improve.
Lets go into the code:
main.cpp
#include &quot;Cat.h&quot;
#include &quot;pet game.h&quot;
#include &lt;iostream&gt;
using namespace std;

int main() {
    //Create the user's profile
    //User();

    //Welcome messages
    cout
            &lt;&lt; &quot;Welcome to Unga bonga! Here you buy pets and raise them as your kids, and try to level up, in order to finish the game!&quot;
            &lt;&lt; endl;
    showHelp();

    //Command execution
    do {
        commandIdentify();
    } while (true);
}
Cat cat;
//User user;

void showHelp() {
    cout &lt;&lt; &quot;The commands in this game are:&quot; &lt;&lt; endl
            &lt;&lt; &quot;1. to feed your cat, type f&quot; &lt;&lt; endl
            &lt;&lt; &quot;2. to clean your cat, type c&quot; &lt;&lt; endl
            &lt;&lt; &quot;3. to check your cat's happiness, type h&quot; &lt;&lt; endl
            &lt;&lt; &quot;4. to check your cash balance, type m&quot; &lt;&lt; endl
            &lt;&lt; &quot;5. to check your level status, type l&quot; &lt;&lt; endl
            &lt;&lt; &quot;6. to display this help message, type ?&quot; &lt;&lt; endl
            &lt;&lt; &quot;7. to exit, type e&quot; &lt;&lt; endl
            &lt;&lt; &quot;8. Finally, to play this game, enjoy!&quot; &lt;&lt; endl;
}
    
void commandIdentify() {
    //take input
    cin &gt;&gt; command;
    //identify and execute
    switch (command) {
    case 'f':
        feedCat();
        break;
    case 'c':
        cleanCat();
        break;
        case 'h':
         checkHappiness();
         break;
    case '?':
        showHelp();
        break;
    case 'e':
        exit();
    default:
        cout &lt;&lt; &quot;That's not a command -yet (probably)&quot; &lt;&lt; endl;
    }
}

void feedCat() {
    cout &lt;&lt; &quot;Time for food!!!&quot; &lt;&lt; endl;
    cat.feed();
}

void cleanCat() {
    cout &lt;&lt; &quot;Let's take a bath!!!&quot; &lt;&lt; endl;
    cat.clean();
}

void checkHappiness(){
 cat.checkHappiness();
 }

int exit() {
    exit(0);
    return 0;
}

pet game.h:
    #ifndef PET_GAME_H_
#define PET_GAME_H_

#include &lt;iostream&gt;
#include &quot;Cat.h&quot;
//#include &quot;User.h&quot;

using namespace std;

//Global variables
char command;
int exit();

//functions
void commandIdentify();
void buyNextCat();
void showHelp();
void tutorial();
void feedCat();
void cleanCat();
void checkHappiness();

//functions defined for a future use but they cause problems right now
void checkMoney();
void checkLevel();


#endif /* PET_GAME_H_ */

Cat.cpp:
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &quot;Cat.h&quot;

using namespace std;

Cat::Cat(){
    happiness = 1;
    cleanness = 1;
}

void Cat::feed(){
    cout &lt;&lt; &quot;Yummy!!&quot; &lt;&lt; endl;
    Cat::happiness = Cat::happiness + 0.2;
}

void Cat::clean(){
    cout &lt;&lt; &quot;So soupy!!&quot; &lt;&lt; endl;
    Cat::cleanness = Cat::cleanness + 0.2;
}

Cat.h:
#ifndef CAT_H_
#define CAT_H_

#include &lt;iostream&gt;

using namespace std;

class Cat {
private:
    int happiness;
    bool happy = happiness &gt;= 0.6;

    int cleanness;
    bool isClean = cleanness &gt;= 0.6;
public:
    Cat();
    void feed();
    void clean();
    void checkHappiness() {
        cout &lt;&lt; &quot;Your cat's happiness is &quot; &lt;&lt; happiness*100 &lt;&lt; &quot;%&quot; &lt;&lt; endl;
    }

};

#endif /* CAT_H_ */

it will be great if you could tell me how to improve code
Avoid using namespace std; - it can cause problems with name collisions. It's best to qualify names where necessary, e.g.: std::cout



std::endl adds a newline, but it also flushes the output stream. Unless we actually need the flushing behavior, it's best to simply output a newline &quot;\n&quot; where necessary (e.g. &lt;&lt; &quot;2. to clean your cat, type c\n&quot;).



char command; does not need to be a global variable. It's only accessed in a single function, so it can be a local variable.



The exit() function is not necessary. We can call std::exit(0) directly. Note that we should include &lt;cstdlib&gt; for this function, and use the exit codes EXIT_SUCCESS or EXIT_FAILURE instead of a number like 0.



Functions that are used only in a single file do not need to be declared in header files. If necessary, we can declare them above the point of use, or move the function definition higher up the file. e.g.:
void commandIdentify(); // forward declaration

int main() { ... }

void commandIdentify() { ... } // function definition

or
void commandIdentify() { ... } // function definition

int main() { ... }





In the Cat class, the happy and isClean members are not quite correct. They will only be set on initialization. If the cat's happiness or cleanness changes at a later time, they will not be updated. In addition, initialization of variables occurs before the body of the constructor, in the order that they are declared in the class.
For the initial values of happy and isClean to be set correctly, we would have to use a member initializer list:
Cat::Cat():
    happiness(1),
    /* `happy` is initialized here */
    cleanness(1),
    /* `isClean` is initialized here */
{
    // if we set happiness now, `happy` won't get updated!
    happiness = 0.2,
}

In any case, since we want the values to always be updated, we should make happy and isClean member functions instead:
bool isClean() const { return cleanness &gt;= 0.6; }

That way, we don't need to update any extra state.




Member functions that don't modify the state of the class (i.e. any member veriables) should be declared const, e.g.:
void checkHappiness() const { ... }





Cat cat; This doesn't need to be a global variable. We can make the cat a local variable in main() and pass a reference to it to the functions that need to use it:
int main() {
    Cat cat;
    ...
    commandIdentify(cat);
}

void commandIdentify(Cat&amp; cat) {
    ...
    feedCat(cat);
}

void feedCat(Cat&amp; cat) {
    ...
    cat.feed();
}

This may seem like more work, but it's quite important, as means that our commandIdentify function (and the functions for each command) will now work with any cat, not just the one cat that we declared in main().
So now we can feed many cats!