project

i have a project due for school in a couple weeks. it can be almost anything. but it has to have these criteria.

•File input/output (I/O)
•Selection
•Repetition
•User- defined functions
•Arrays and strings

i am just looking for suggestions for a type of game , something that is a little challenging but not above my level, which is beginner . i am in my first term of code writing
How about making a virtual pet? If Selection and Repetition stand for if/switch and for/while statements, then you'll get done with these requirements just with your game menus :P (usually implemented as a switch statement inside a while statement). Adding the option to save/load your pet will fulfill the first requirement. You can then add functions like play and feed to interact with your pet. In fact, you could allow the user to have more than one pets (arrays). And a pet's name can be represented by a string.
Last edited on
ok , there would be no picture of a pet , so would the pet tell you he/she was hungry or thirsty? would i have to put a menu of commands like feed , water , pet and such?
That's what I have in mind...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

const int MAX_PETS=5;

string name[MAX_PETS];
int hungry[MAX_PETS];
int thirsty[MAX_PETS];
int happy[MAX_PETS];

void feed(int pet_id);
void water(int pet_id);
void play(int pet_id);
void show_status(int pet_id);

void save_pets();
void load_pets();

void main_menu();

void game_menu();
void game();

int main()
{
    int choice;

    while (true)
    {
        main_menu();

        cin>>choice;
        if (/*quit*/) break;

        switch (choice)
        {
            case 1:
            game();
            break;
            //...
        }
    }

    cin.get();
    return 0;
}

void main_menu()
{
    //new game
    //save pets
    //load pets
    //credits
    //quit
}

void game_menu()
{
    //view pet status
    //feed pet
    //water pet
    //play with pet
    //exit to main menu
}

void game()
{
    int action;
    int pet;

    while (true)
    {
        game_menu();

        cin>>action;
        if (/*quit*/) return;

        cin>>pet;

        switch (action)
        {
            case 1:
            show_status(pet);
            break;
            //...
        }
    }
}
Topic archived. No new replies allowed.