Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string.h>
- #include "stack.h"
- using namespace std;
- Stack::Stack()
- {
- top = 0;
- }
- bool Stack::isempty() const
- {
- return top == 0;
- }
- bool Stack::isfull() const
- {
- return top == MAX;
- }
- bool Stack::push(const Item & item)
- {
- if (top < MAX)
- {
- items[top++] = item;
- return true;
- }
- else
- return false;
- }
- bool Stack::pop(int delnum)
- {
- if (top == 1)
- {
- top--;
- return true;
- }
- else if(top>1)
- {
- for(int i=delnum;i<top-1;i++)
- {
- strcpy(items[i].fullname,items[i+1].fullname);
- items[i].payment = items[i+1].payment;
- }
- top--;
- return true;
- }
- else
- return false;
- }
- void Stack::list()
- {
- cout<<"|Num/Name/Payment Amount/|"<<endl;
- for(int i=0;i<top;i++)
- cout<<"|"<<i+1<<"/"<<items[i].fullname<<"/"<<items[i].payment<<"|"<<endl;
- }
- void Stack::stack_del(char *name)
- {
- customer db;
- int cnt;
- for(int i=0;i<top;i++)
- {
- char *tmp = items[i].fullname;
- if((strcmp(tmp,name))==0)
- {
- Stack::pop(i);
- cnt++;
- }
- }
- if(cnt==0)
- {
- cout<<"고객이름이 리스트가 없습니다."<<endl;
- return;
- }
- else
- {
- cout<<"정상적으로 처리되었습니다."<<endl;
- return;
- }
- }
- int Stack::payment(void)
- {
- int amount=0;
- for(int i=0;i<top;i++)
- {
- amount+=items[i].payment;
- }
- top=0;
- return amount;
- }
Add Comment
Please, Sign In to add comment