File size: 1,337 Bytes
e1191aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <string>
using std::string;

#include <iostream>
using std::cin;
using std::cout;
using std::stringstream;

#include <sstream>
#include "StacksAD.cpp"

using namespace std;


class StacksDP
{
private:
    Nodo *FirstNode, *tempNode;
public:
    string push(string info){
        if(FirstNode == NULL){
            FirstNode = new Nodo(info);
            FirstNode->setNext(NULL);
            return "Exitosamente Guardado: "+info;
        }
        else{
            tempNode = FirstNode;
            FirstNode = new Nodo(info);
            FirstNode->setNext(tempNode);
            return "Exitosamente Guardado: " + info;
        }
    }
    string pop(void){
        
        if (FirstNode == NULL) {
            return "EMPTY LIST";
        }
        
        string result = FirstNode->getString();
        FirstNode = FirstNode->getNext();
        return result;
    }
    string desplegar(void){
        string result ="";
        
        if (FirstNode == NULL) {
            return "NULL LIST";
        }
        
        Nodo *cursor = FirstNode;
        while(cursor!=NULL){
            result += cursor->getString() +"\n";
            cursor = cursor->getNext();
        }
        return result;
    }
    void getData(void);
    void saveData(void);

};