You\'re a developer for a startup called HowU Study that matches study buddies f
ID: 3575841 • Letter: Y
Question
You're a developer for a startup called HowU Study that matches study buddies for classes depending on the experience of each user. In this lab you must:
using objects, classes, vectors, structs, and or functions! create a C++ class called User that contains the following below. You can include constructor(s) if you want.
name
classification
major
expert class list (what classes the user feels they are an expert in)
mutators and accessors for each private variable
printUsers function that prints all the users of the system
matchStudyBuddy function that matches users based on classes they have in common. (Meaning two or more classes that match)
read a set of users from a file userData.txt
read in a whole line from the file
parse the line, you will have to change the delimiter of the getline statement to be comma delimited
Use this as an example
Make sure to print a table showing all the users and their potential matches for studying in one column
Explanation / Answer
class user
{
string name;
string classification;
string major;
vector<string> exp_list;
public:
};
void printUsers(user a[])
{
int no_of_user=sizeof(a)/sizeof(a[0]);
int i;
for(i=0;i<no_of_user;i++)
{
cout<<i+1<<". "<<a[i].name<<endl;
}
}
void matchStudyBuddy(user a[])
{
int no_of_user=sizeof(a)/sizeof(a[0]);
int i,j;
bool vis[no_of_user];
memset(vis,false,sizeof vis);
for(i=0;i<no_of_user;i++)
{
if(!vis[i])
{
for(j=0;j<no_of_user;j++)
{
if(!vis[j] && i!=j)
{
if(strcmp(a[i].classification,a[j].classification))
cout<<a[j].name<<endl;
vis[j]=true;
}
}
}
vis[i]=true;
}
}
int main()
{
string line;
user *a;
ifstream in;
in.open("userData.txt");
while(!in.eof)
{
getline(in,line);
//arrange user's data according to input file data
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.