Tuesday, 14 May 2013

C++ Stack - Part 3


Below is the manipulation of the objects created with the stack data type inside the main function. This final C++ stack source code is used in collaboration with part 1 and part 2.


#include<iostream>
#include "part1_filename.h"    

using namespace std;


int main()
{
     int choice;
     stack Abacus;
     int element;
     while(1)
        {
             cout <<"Select a number for an action you want to perform";
             cout<<endl;
             cout<<endl;
             cout <<"1 - Insert an element into the stack";
             cout<<endl;
             cout<<"2 - Remove an element from the stack";
             cout<<endl;
             cout<<"3 - View the elements of the stack";
             cout<<endl;
             cout<<"4 - See the size of the stack";
             cout<<endl;
             cout<<"5 - End";
             cout<<endl;
             cout<<endl;
             cout <<"Enter your choice: ";
             cin >> choice;
             switch(choice)
           {
               case 1:  cout <<"Input a number: ";
                        cin >> element;
                        cout <<"\n";
                        Abacus.Push(element);
                        break;
                        
               case 2:   
                         Abacus.Pop(); 
                         break;
                   
               case 3:
                         Abacus.Print();
                         break;
                    
               case 4: 
                         Abacus.getSize();
                         break;
                      
               case 5:   exit(0);
               }
         }
         system("pause");
         return 0;
}

The code and its associates are fully functional. There are a few changes to be made and the code can be run on any c++ compiler. 

Feel free to suggest some changes on the source codes.


C++ Stack - Part 2


The stack's function definitions and implementations. To view the stack interface go to part 1.


#include<iostream>
#include "part1_filename.h"    

using namespace std;

stack::stack()                 
{
     top = -1;
}

stack::~stack(){ }

bool stack::Push(int x)
{

    if(IsFull())
    {
        cout <<"The stack is full!"<<endl;
        return 0;
    }
    arrayStack[++top] = x;
}

bool stack::Pop()
{
    if( IsEmpty() )
    {
        cout <<"The stack is empty";
        cout<<endl;
        return 0;
    }
    else
    cout<<arrayStack[top--]<<"  has been removed from the stack"<<endl;
}

bool stack::IsEmpty()
{    
    return (top == -1);
     
}

bool stack::IsFull()
{
   return (top > 8);  
}

void stack::Print()
{
    for(int z=top; z>=0; z--){
    cout <<arrayStack[z] <<"    ";
    }
    cout<<endl;
}

int stack::getSize()
{
    top = top + 1;
    cout << top;
}

Save this block of code in the same folder as the header file in part one. Part three will cover the main function.

C++ Stack - Part 1


Part one covers only the class interface of the stack. Basically, a stack is a data type which follows Last-In-First-Out rule.



#ifndef STACK_H
#define STACK_H    

using namespace std;

class stack
{
    public:
        stack();    // Constructor
        ~stack();  // Destructor
        bool Push(int x); // A Function that inserts an element into the stack 
        bool Pop(); // A Function that deletes an element from the stack        
        bool IsEmpty(); // A function that determines if the stack is empty
        bool IsFull(); // A function that determines if the stack is full
        void Print(); // A Function that prints all elements in the stack
        int getSize(); // A function that returns the number of elements in the stack
                 
    private:
        int top; // A variable that indicates the position of the last element
        int arrayStack[10]; // An array that contains the elements of the stack

};
#endif

Your file name is very important here, because in Part two, which will be the function definitions and implementation will be used.

Saturday, 4 May 2013

9 Lies and The Truth


1.  I’m too busy
2.  Everybody hates me
3.  I tried over and over and over again
4.  I’m not meant for this
5.  I’m such a fool
6.  I've already failed
7.  I’m not a genius
8.  I’m too young
9.  It has always been this way

1.  You’re fearfully and wonderfully made. Stop. Read that again.

Yes, the truth is, you’re fearfully and wonderfully made.

Tuesday, 30 April 2013

Frequently Asked Questions (FAQ)


As we're celebrating the workers day in my country, I thought about some questions which would somehow be ambiguous but they're actually not. My assumption is that they're frequently asked and therefore I give frequently awesomely ignored answers to them. 


  Q - "Been calling, why didn't you pick your phone?"
  A - "Oh! Oh! My phone! It had not fallen down!"



 Q - "Your hair looks beautiful, what have you done to it?"
 A - "Nothing! You know, I've seen people feed their hair some cream called ’Hair Food’ and it grew faster. I've also seen some let their hair go hungry and turned into bald heads!"



 Q - "Are you a player?"
 A - "What are talking about? I don’t play for any team!"



 Q - "So can I have your number so I can call you?"
 A - "I don’t think that’s a good idea. Don’t call me, I’ll call you!"


Caution!
If you happen to be asked any of these questions, never use any of the answers here unless your rude by yourself!


Happy Workers Day!


Friday, 26 April 2013

Human Factors and Outsourcing


After completing a term paper at college, I thought I should share a portion from it. As the title says, it is about the effects of human factors on outsourcing.

 To begin with, communication between parties involved in outsourcing plays a vital role as most of the processes towards outsourcing have to be discussed. These include the discussions of the objectives and the tasks allocated to the company taking the outsourced functions. However, differences in interpreting the content can cause a potential error. 

Another human factor closely related to communication is the language barrier. As a company may outsource their functions to companies abroad, language barriers may pose a great problem to the companies. The only question that would be asked is: “How will the language barrier problem be overcome?” In such cases, hiring translators to bridge that gap proves handy.

Due to the growth of the outsourcing market and the increasing workload in outsourcing maintenance, most of the companies rely on temporary employees or un-certified personnel. Most of these temporary workers shift from one company to another in order to meet their peak workload. 

However, those temporary workers have to learn new set of procedures every time when they move to a new organisation; this may potentially cause a problem. Never the less, to minimize this procedure error, companies need to strengthen their internal training programmes.

Let's hear your thoughts...