Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Program : This is one program with multipule requriements, which should be d

ID: 645331 • Letter: C

Question

C++ Program: This is one program with multipule requriements, which should be done on visual studio or similar. The idea behind this program is to build a twitter like system that has user accounts, shout-outs (instead of tweets), followers, etc. The goal of this program is to allow users to log into the system and and be presented with their history of shout-outs as well as shout-outs that have happened since the last time they logged in.

NOTE: All shoutouts and user information must be stored in files that are read at the start of the program. This information is only written back to the files before the program closes. There should be no file access during the execution.

Detailed Description

This program should only allow the user to use the system if they have an account. Account information and shout-outs need to be saved between executions of the program to files. The following list is the functionality that should be available to registered users:

Create user account

Login into account

Add, remove, and search operations on your following list

Add, remove, and search operations on your followers list

View your following list sorted by name (users that you are following)

View your followers list sorted by name (users that follow you)

View your shout-outs

View your private shout-outs

remove public and private shout-outs

Post a shout-out

Send a shout-out

The shout-out view shows all of the shout-outs the user has made and those sent to them by their followers. When you view the followers list or the following list, then the user should have the option to see the shout-outs for that user. Posting a shout-out is where the user post to their shout-out list for others to see, and sending a shout-out is where the user sends a shout-out to a friend. The shout-outs posted by the user show on their list of shout-outs and their followers list. The shout-outs sent to other users show up on that user's private shout-out list. The user that receives the shout-out has the option to re-shout the shout-out which means it will behave as a post. The reshout should indicate which user sent the shout-out originally.

The add to following option is where a user can become a member of another users followers list. Therefore a users following list is updated at the same time another users followers list is updated. The user can then view their following and followers list.

When the user logouts, the program should not stop. It should allow another login. There can be an exit option to stop the program.

Input

This program has interactive input to allow users to login and use the functionality of the system; this can be done with menus, commands, etc. However, the shout-outs for each user should be stored in one or more files. The file organization is up to you. The account information, list of followers, list of following, etc. should also be stored in one or more files. This file organization is also your decision.

Output

Your output will be screen output for selected options and those results. You will also have to update appropriate files when shout-outs are posted or when followers/following list are updated.

Thank you for your time

Explanation / Answer

<!-- browser toolbar -->

<div id="toolbar">

    <button id="goback-button" type="button" disabled><</button>

    <button id="goforward-button" type="button" disabled>></button>

    <!-- url bar displays page url or page title -->

    <form id="url-bar">

        <input id="url-input" type="text"></input>

    </form>

    <button id="url-button" form="url-bar">GO</button>

</div>

<!-- the container for the browser frame -->

<div id="frame-container" class="empty">

    <div id="empty-frame">

        <h1>Hello myBrowser!</h1>

    </div>

</div>

/**

* Returns an iframe which runs in a child process with Browser API enabled

* and fullscreen is allowed

*

* @param {String} [url] Optional URL

* @return {iframe}       An OOP mozbrowser iframe

*/

function createIFrame (url) {

var iframe = document.createElement('iframe');

iframe.setAttribute('mozbrowser', true);

iframe.setAttribute('mozallowfullscreen', true);

iframe.setAttribute('remote', true);

if (url) {

    iframe.src = url;

}

return iframe;

}

/**

* The browser tab constructor.

*

* Creates an iframe and attaches mozbrowser events for web browsing.

*

* Implements EventListener Interface.

*

* @param {String} url An optional plaintext URL

*/

function Tab (url) {

this.iframe = createIFrame(url);

this.title = null;

this.url = url;

this.iframe.addEventListener('mozbrowserloadstart', this);

this.iframe.addEventListener('mozbrowserlocationchange', this);

this.iframe.addEventListener('mozbrowsertitlechange', this);

this.iframe.addEventListener('mozbrowserloadend', this);

this.iframe.addEventListener('mozbrowsererror', this);

};

Tab.prototype.mozbrowsertitlechange = function _mozbrowsertitlechange (e) {

if (e.detail) {

    this.title = e.detail;

}

var event = new CustomEvent('tab:titlechange', { detail: this });

window.dispatchEvent(event);

};

Code can now be added to the main app.js to handle this custom event, which updates the title.

/**

* Display the title of the currentTab on titlechange event.

*/

window.addEventListener('tab:titlechange', function (e) {

if (currentTab === e.detail) {

    urlInput.value = currentTab.title;

}

});

/**

* The default search engine URI

*

* @type {String}

*/

var searchEngineUri = 'https://search.yahoo.com/search?p={searchTerms}';

/**

* Using an input element to check the validity of the input URL. If the input

* is not valid, returns a search URL.

*

* @param {String} input           A plaintext URL or search terms

* @param {String} searchEngineUri The search engine to be used

* @return {String}                 A valid URL

*/

function getUrlFromInput(input, searchEngineUri) {

var urlValidate = document.createElement('input');

urlValidate.setAttribute('type', 'url');

urlValidate.setAttribute('value', input);

if (!urlValidate.validity.valid) {

    var uri = searchEngineUri.replace('{searchTerms}', input);

    return uri;

}

return input;

}

Code can then be added to the main app.js to handle the submit button. This code checks to see if a currently active Tab object exists, and either loads the URL or reloads the URL if it has not changed. If one does not exist, it is created and the URL is loaded.

/**

* Check the input and browse the address with a Tab object on url submit.

*/

window.addEventListener('submit', function (e) {

e.preventDefault();

if (!currentUrlInput.trim()) {

    return;

}

if (frameContainer.classList.contains('empty')) {

    frameContainer.classList.remove('empty');

}

var url = getUrlFromInput(currentUrlInput.trim(), searchEngineUri);

if (!currentTab) {

    currentTab = new Tab(url);

    frameContainer.appendChild(currentTab.iframe);

} else if (currentUrlInput === currentTab.title) {

    currentTab.reload();

} else {

    currentTab.goToUrl(url);

}

});

The currentTab.reload function uses the iframe.reload function provided by the Browser API to reload the page. The code below is added to the tab.js file to handle the reload.

/**

* Reload the current page.

*/

Tab.prototype.reload = function _reload () {

this.iframe.reload();

};

/**

* Check if the iframe can go backward in the navigation history.

*

* @return {Promise} Resolve with true if it can go backward.

*/

Tab.prototype.getCanGoBack = function _getCanGoBack () {

var self = this;

return new Promise(function (resolve, reject) {

    var request = self.iframe.getCanGoBack();

    request.onsuccess = function () {

      if (this.result) {

        resolve(true);

      } else {

        resolve(false);

      }

    };

});

};

The check is performed in the app.js file when a page is loaded. This occurs when the iframe receives a mozbrowserloadend event.

/**

* Enable/disable goback and goforward buttons accordingly when the

* currentTab is loaded.

*/

window.addEventListener('tab:loadend', function (e) {

if (currentTab === e.detail) {

    currentTab.getCanGoBack().then(function(canGoBack) {

      gobackButton.disabled = !canGoBack;

    });

     currentTab.getCanGoForward().then(function(canGoForward) {

      goforwardButton.disabled = !canGoForward;

    });

}

});

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote