GetACoder.com

 
 

Home | My Account | Post Project | Browse Projects | RSS Feeds New!

 

Simple C++ Console Program

 
 
Download the Free Step-by-Step Guide
     
Budget: $ 20-100
Status: Closed for Bidding (selected user dynamic03bd)
Project Creator:
yboioPirateWorld  
  10.00/1010.00/1010.00/1010.00/1010.00/1010.00/1010.00/1010.00/1010.00/1010.00/10 3 reviews
Required Skills: C++ / C
Attached Files: (None)
 
post new project
email this project
discuss this project
send private message to project creator
more options

NEW

SEND

DISCUSS

CONTACT

OPTIONS

Description
You are required to implement a simple command prompt for manipulating an ordered list of numbers. In completing this project you will need to exploit the concepts of stacks, queues, and searching.

At their core, a command prompt will display a prompt to the user and process the commands that they type in. The commands that you are required to implement for this application are all single word commands, as follows:

* add - prompts the user for a number and stores that number in the ordered list;
* remove - prompts the user for a number and removes that number from the ordered list (if it is present);
* show - display the current contents of the ordered list;

* exit - terminates the program;
* help - displays a list of the valid commands;
* history - displays the most recent commands;

* undo - undoes the last add/remove command; and
* redo - redoes the last command undone (if any).

There are no restrictions on how you implement the above functionality, beyond the following points:

1. The standard C++ programming language must be used, you may not use any kind of library or example code for a command prompt application;
2. Any STL type/s can be used in accomplishing the required functionality;
3. A queue of some description must be used for the command history;
4. Stacks must be used for the undo and redo commands; and
5. Duplicates are not permitted in the list.

The tasks listed below provide further information/requirements. You do not need to strictly follow the order of these questions. Below the questions is an example run of such an application to allow you to see the final solution in operation. Your output does not need to match this example, but it must be reasonably intuitive.

The following main function may help you to get started (you do not need to use this however):

int main(int argc, char *argv[])
{
string input;

cout < \";
cin >> ws >> input;
while(input != \"exit\")
{
if(input == \"add\")
{
/* code to handle add command */
}
else if(input == \"help\")
{
cout << \"Commands:\" << endl;
cout << \"\tadd exit help history\" << endl;
cout << \"\tredo remove show undo\" << endl;
}
else if(input == \"history\")
{
/* code to handle history command */
}
else if(input == \"redo\")
{
/* code to handle redo command */
}
else if(input == \"remove\")
{
/* code to handle remove command */
}
else if(input == \"show\")
{
/* code to handle show command */
}
else if(input == \"undo\")
{
/* code to handle undo command */
}
else
{
cout << \"Invalid command.\" << endl;
}

cout < \";
cin >> ws >> input;
}
}

TASK 1

Implement the functionality for the add, remove, and show commands. Remember that duplicates are not permitted.

TASK 2

Implement the command prompt history and the history command, remembering that a queue must be used for this purpose. The following notes provide information and requirements:

* When a command is entered it is enqueued in the queue. Note that all commands should be stored in the list, regardless of whether they are valid or not, or succeed or not;
* The history must be limited to 10 commands.

TASK 3

Implement the undo and redo commands. For this purpose, you will need an \"undo stack\" and a \"redo stack\". The operation of these stacks is as follows:

* When an add or remove command is successfully completed, an entry is pushed onto the undo stack recording the operation;
* When the undo command is entered, if there is anything on the undo stack it is popped off the stack and the recorded operation is undone;
* Whenever an operation is undone, an entry is pushed onto the redo stack recording the operation;
* When the redo command is entered, if there is anything on the redo stack it is popped off the stack and the recorded operation is redone;
* Whenever an operation is redone, an entry is pushed onto the undo stack recording the operation; and
* Whenever an add or remove command is successfully completed, the redo stack is cleared.

Consider the following example which illustrates the ordered list, undo stack, and redo stack, throughout the operation of the following commands:

1. add 5
2. add 10
3. add 12
4. undo
5. undo
6. redo
7. redo
8. undo
9. remove 10
10. undo
11. add 15

Initial state:

List:

Undo stack:

*

Redo stack:

*

After add 5:

List: 5

Undo stack:

* add 5

Redo stack:

*

After add 10:

List: 5, 10

Undo stack:

* add 10
* add 5

Redo stack:

*

After 'add 12':

List: 5, 10, 12

Undo stack:

* add 12
* add 10
* add 5

Redo stack:

*

After undo:

List: 5, 10

Undo stack:

* add 10
* add 5

Redo stack:

* add 12

After undo:

List: 5

Undo stack:

* add 5

Redo stack:

* add 10
* add 12

After redo:

List: 5, 10

Undo stack:

* add 10
* add 5

Redo stack:

* add 12

After redo:

List: 5, 10, 12

Undo stack:

* add 12
* add 10
* add 5

Redo stack:

*

After undo:

List: 5, 10

Undo stack:

* add 10
* add 5

Redo stack:

* add 12

After remove 10:

List: 5

Undo stack:

* remove 10
* add 10
* add 5

Redo stack:

*

After undo:

List: 5, 10

Undo stack:

* add 10
* add 5

Redo stack:

* remove 10

After add 15:

List: 5, 10, 15

Undo stack:

* add 15
* add 10
* add 5

Redo stack:

*

Example Run

Below is an example run of a solution to the above project using a similar sequence of operations to those used in the example in Task 4. The show command is used throughout to show the contents of the ordered list and the count of elements in both stacks. The other commands are also demonstrated in the script. The \"command prompt\" used in the solution is a simple greater-than symbol (>). User input has been highlighted in red.

> help
Commands:
add exit help history
redo remove show undo
> show
List:
Undo stack: 0 entry/entries
Redo stack: 0 entry/entries
> add
Number> 5
Succeeded.
> show
List: 5
Undo stack: 1 entry/entries
Redo stack: 0 entry/entries
> add
Number> 5
Failed.
> show
List: 5
Undo stack: 1 entry/entries
Redo stack: 0 entry/entries
> add
Number> 10
Succeeded.
> show
List: 5 10
Undo stack: 2 entry/entries
Redo stack: 0 entry/entries
> add
Number> 12
Succeeded.
> show
List: 5 10 12
Undo stack: 3 entry/entries
Redo stack: 0 entry/entries
> undo
Succeeded.
> show
List: 5 10
Undo stack: 2 entry/entries
Redo stack: 1 entry/entries
> undo
Succeeded.
> show
List: 5
Undo stack: 1 entry/entries
Redo stack: 2 entry/entries
> redo
Succeeded.
> show
List: 5 10
Undo stack: 2 entry/entries
Redo stack: 1 entry/entries
> redo
Succeeded.
> show
List: 5 10 12
Undo stack: 3 entry/entries
Redo stack: 0 entry/entries
> undo
Succeeded.
> show
List: 5 10
Undo stack: 2 entry/entries
Redo stack: 1 entry/entries
> remove
Number> 10
Succeeded.
> show
List: 5
Undo stack: 3 entry/entries
Redo stack: 0 entry/entries
> undo
Succeeded.
> show
List: 5 10
Undo stack: 2 entry/entries
Redo stack: 1 entry/entries
> add
Number> 15
Succeeded.
> show
List: 5 10 15
Undo stack: 3 entry/entries
Redo stack: 0 entry/entries
> some_invalid_command
Invalid command.
> history
History:
undo
show
remove
show
undo
show
add
show
some_invalid_command
history
> exit
Press any key to continue . . .

Reminder
You may not start working in this and any project before your bid is accepted. Any user who violates this policy may have their account permanently suspended.

Place Bid | Post Similar Project | Send Project | Message Board(0) | Contact yboioPirateWorld

Order by:

 

 yboioPirateWorld has chosen to keep all bids for this project hidden

 

Remember that contacting the other party outside the site (by email, phone, etc.) on all business projects (before the project is awarded) is a violation of our terms of use. We supervise all site activity for such infringements and can immediately expel transgressors on the spot, so we thank you in advance for your cooperation. If you notice a violation please help out the site and report it. Thank you for your help.
 

          nbsp;    

 


 
Get the Free Step-by-Step Guide on How to Use GetACoder
The act of outsourcing projects has become easy in the past few years thanks to GetACoder. However, our team aims at making the whole process even easier. So, it has now come the time to provide you with a step-by-step guidance on how to use this service and succeed in the outsourcing world totally for FREE.

It doesn’t matter if you are a more experienced user or a novice; using GetACoder will become even simpler with the help of this E-book. There are two major sections: a Buyers section and a Coders section.

Buyers will learn:
  • How to outsource safely
  • How to pick the best freelancers
  • How to manage time and money

Coders will learn:

  • How to get the best projects
  • How to secure their payments
  • How to build a long-lasting relationship with buyers

    …and  MUCH MORE
Clear examples and pictures illustrating key situations, great tips and real testimonies of some of our best users… all in this Outsourcing Guide.  So don’t loose the outstanding opportunity to download GetACoder FREE E-book.
The Outsourcing Revolution: Why It Makes Sense and How to Do It Right
The Outsourcing Revolution: Why It Makes Sense and How to Do It Right
What is GetACoder?

GetACoder.comGetACoder is a leading Global Services Marketplace doing business in more than 200 countries. Our unique system accelerates your time to market and provides your business with key competitive advantages. When you use GetACoder you are stretching your budget and saving as much as 60% over traditional outsourcing. GetACoder is changing business, now it's no longer about what you own or build but which resources and talent you can access. With GetACoder you reduce expenses, increase efficiencies, aggressively grow your business, and create a sustainable competitive advantage. GetACoder makes outsourcing to any part of the world an easy task! With GetACoder it's simple to outsource any business project, gain access to global talent and manage projects online.

One of the main advantages of GetACoder is the low labor cost. The typically rates are about seven times lower than the ones in the US or Europe. Posting a project at GetACoder allows the right professional or company to find you and to bid for your work. We are building a reputation for exceeding our customers' expectations and for becoming an extremely cost effective way to outsource work. Use GetACoder when you want to save money, increase efficiency or accelerate the development of your project. With GetACoder you focus on growing your business and let others do the tedious work. Post your project on GetACoder for free. Find out why people outsource projects with us day after day.

Thousands of Satisfied Customers - Submit/View Quotes


-We have been getting a lot of projects on GetACoder, which is a well-planned, very friendly website offering projects in every domain, with a nice, efficient bidding and messaging system, Escrow and release payments which secures both the clients & solution providers. - ranosoft
-GetACoder is an excellent website. I got 5 projects within a month. It is really a nice site with an excellent payment system. I received my money within 5 days like they said. Another thing that impressed me is that you can call your money at anytime you wish, which is really an excellent feature. They also have a large list of payment providers, which is a good thing, as well. Thank you for making such a nice site for us to get projects. - rattanisoft
-It's really an amazing site, i am very happy to find GetACoder. - heliconstudio
Report Violation    Privacy Policy     Affiliate Program    Terms of Use    Contact Us    Help      GetACoder.com Latest Projects RSS Feed
© 2004-2008 GetACoder. All rights reserved.