コード例 #1
0
int main() {
	UserNetwork network = UserNetwork();
	//vector<User> users;
	/*User user;
	int random;
	typedef std::minstd_rand G;
    G g;
    typedef std::uniform_int_distribution<> D;
    D d(0, 9999);

	for(int i = 0; i < 10000; i++) {
		user = User(to_string(i),"a",to_string(i),"MB");

		user.addPost(WallPost(to_string(i + 100), to_string(i)));
		user.addPost(WallPost(to_string(i + 99), to_string(i)));
		user.addPost(WallPost(to_string(i + 500), to_string(i)));
		user.addPost(WallPost(to_string(i + 1000), to_string(i)));

		network.addUser(user);
		users.insert(users.begin(), user);
		
	}

	for (auto iter = users.begin(); iter != users.end(); ++iter) {
		for (int j = 0; j < 100; j++) {
			random = d(g);
			cout << random << endl;
			iter->sendFriendRequest(to_string(random)	, &network);
		}
	}

	for (auto iter = users.begin(); iter != users.end(); ++iter) {
		for (auto request = iter->getFriendRequests().begin(); request != iter->getFriendRequests().end(); ++request) {
			random = d(g);
			cout << random << endl;
			iter->acceptFriendRequest(*request, &network);
		}
	}
*/
	network.readFromFile();
	for (auto iter = network.getUsers()->begin(); iter != network.getUsers()->end(); ++iter) {
		//iter->setFriendRequestPointers();
		bool going = true;
		while(going) {// = iter->getFriendRequests().begin(); request != iter->getFriendRequests().end(); ++request) {
			cout << iter->toString() << endl;
			try {
				iter->acceptFriendRequest(iter->getFriendRequests().at(0), &network);
			} catch(std::out_of_range& e) {
				going = false;
			}
			cout << iter->toString() << endl;
		}
	}
	network.toFile();
	return 0;
}
コード例 #2
0
int main(int argc, const char * argv[]) {


    // make a usernetworklist
    UserNetwork test;
    string username = "";
    test.addUser("krishna", "sup", "Krishna Ling", "S");
    test.addUser("vince", "hi", "Vince Gan", "Be");
    test.addUser("vince2", "hi2", "Vince Gan2", "Be2");
    test.addUser("vince3", "hi3", "Vince Gan3", "Be3");
    test.addUser("vince4", "hi4", "Vince Gan4", "Be4");
    test.WriteToFileUserList();

    test.readFromFile("./userList.txt");

    //cout << test.returnUser("krishna").userInfoString();
    //cout << test.returnUser("vince").userInfoString();

    test.sendRequest("vince", "krishna");
    test.sendRequest("vince", "vince2");
    test.sendRequest("vince", "vince3");
    test.sendRequest("vince", "vince4");
    test.acceptRequest("krishna", "vince");
    test.acceptRequest("vince2", "vince");
    test.acceptRequest("vince3", "vince");
    test.acceptRequest("vince4", "vince");
    cout << test.returnUser("vince").printFriendsList() << endl;


//    int counter;                                       // if counter = 1 then password exists
//    string yourpass;
//    cout << "Enter Password: "******"Password exists" << endl;
//            return 0;
//        }
//        itr++;
//    }
//
//
//    if(counter !=1){
//        cout << "Password does not exist"<< endl;
//    }


    return 0;
}
コード例 #3
0
int main() {
	/*std::ifstream myfile;
	myfile.open("users.txt"); //default modes: ios::in and ios::out for input and output
	std::string user;
	*/
	curr_user = nullptr;
	usernetwork.readFromFile();
	cout << "User Network read from file. " << endl;

	char choice; // command entered by user

	do {
		(loginStatus) ? print_login_menu(uname) : print_menu();
		choice = toupper(get_command());
		switch (choice) {
			//basic functions
		case 'C': //create new user
			createUser();
			break;
		case 'L': //login
			if (!loginStatus)
				userLogin();
			else
				loginStatus = false;
			break;
		case 'Q':
			break;
		case 'A':
			if (loginStatus) {
				addFriend();
				break;
			}
		case 'D': 	//display wall
			if (loginStatus) {
				displayWall(uname);
				break;
			}
		case 'N':	//create new post on wall
			if (loginStatus) {
				createNewPost(uname);
				break;
			}
		case 'E':	// enter my wall
			if (loginStatus) {
				enterPost(curr_user);
				break;
			}
			//debug functions
		case 'P': //print all users
			show_network(usernetwork);
			break;

		case 'F':	// Display my friend
			if (loginStatus) {
				displayAllFriend();
				break;
			}

		case 'I':	// Enter my friend's wall
			if (loginStatus) {
				enterFriendWall();
				break;
			}

		case 'R':	// Get the Route of other user
			if (loginStatus) {
				getTheRoute();
				break;
			}

		case 'S':	// Find my possible friend
			if (loginStatus) {
				getpossibleFriend();
				break;
			}
		default:
			cout << choice << " is invalid." << endl;
		}
	} while (choice != 'Q');

	usernetwork.writeToFile();
	return 0;
}