[cpp] main
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- #pragma once
- #include <iostream>
- #include "user.cpp"
- using namespace std;
- int global_profit; //can also go inside main
- int global_launch;
- int main()
- {
- MaxHeap mheap; //null right now
- string input;
- string instruction;
- bool run = true;
- string user_id;
- string num_votes;
- string kUsers;
- User tempUser;
- Ndoe tempNode;
- //Bst tree instance of class
- //Max heap instance of class object
- while (run)
- {
- cout << "What would you like to do..." << endl; //do yuo want this prompt each time
- cin >> input >> endl; //entire line in here
- //instruction = input.substr(0, input.find(" ")); //shud shorten it
- stringstream ss(input); //may need to switch to char array
- ss >> instruction;
- if(instruction == "register")
- {
- ss >> userid;
- tempUser = User(userid);
- tempNode = Node(tempUser);
- if (BST.search(User) == false)
- {
- BST.insert(tempUser);
- }
- //trailing spaces, but can have spaces like fofr a first name and last name
- }
- else if(instruction == "vote")
- {
- ss >> num_votes;
- ss >> user_id;
- tempUser = User(userid);
- tempNode = Node(tempUser);
- if (num_votes % 2 == 0)
- {
- global_launch = global_launch + (num_votes/2);
- global_profit = global_profit + (num_votes/2);
- }
- else //its odd
- {
- global_launch = global_launch + (num_votes/2);
- global_profit = global_profit + (num_votes/2) + 1;
- //add that number of votes to the user specfied and we dont care where that money comes from
- }
- //add that number of votes to the user specfied and we dont care where that money comes from
- BST.find()
- }
- else if(instruction == "scoreboard")
- {
- ss >> kUsers;
- }
- else if(instruction == "profit")
- {
- cout << "$" << global_profit << endl;
- }
- else {cout << "invalid input..." << endl;}
- // run the check to see if we launch, and iff we do extarct max
- }
- }
Editor
You can edit this paste and save as new: