A friend and I are trying to keep our minds fresh over break by creating a program that rates girls, excuse image that throws...
I am at a road block finding a way to store the information of each girl, such as a string for their name and ints for their scores. I cannot find a way to reference each of them so I can make a comparative statement! My first reaction was to write the data to a file. The program below only stores one number.
Arrays were another idea I looked into. If I understand correctly, data cannot be stored in an array like that.
Well you could try to use an array but you would need to for-loop through the array before/while you put that data into your file.
However, I would be hard-pressed to think that there is any more efficient way of storing a series of data-points and with no iteration to place that data into a file.
Why don't you use a struct for the girl data and store them in a vector? You could easily do all sort of operations like sorting, filtering and searching.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
struct Girl
{
Girl(int cute, int smart, int crazy)
{
this->crazy = crazy;
this->smart = smart;
this->cute = cute;
}
double getRating()
{
returndouble(cute + crazy + smart) / 3.0;
}
int cute;
int smart;
int crazy;
};
Thanks for the suggestions, from both of you. Thomas1965, I do not believe we went over structures in class yet (maybe we did). I will review my textbook and research into both suggestions. I may private message you moving forward. :)