-
Notifications
You must be signed in to change notification settings - Fork 0
/
LinkedList.cpp
53 lines (44 loc) · 1.41 KB
/
LinkedList.cpp
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
//
// Created by rafli on 25/06/2019.
//
#include <iostream>
#include <string>
#include <iomanip>
#include "LinkedList.h"
using namespace std;
void LinkedList::showHistory() { //Use linkedlist to check the history and if the there's no data it will print out
Node * temp = head;
if(temp == NULL){
cout <<"There is no data" << endl;
}
else{
while(temp!= NULL){
cout << left << setw(20) << temp->name; //If there's a data, then it will print out based on the table
cout << left << setw(20) << temp->shoes;
cout << left << setw(30) << temp->service;
cout << left << setw(30) << temp->time;
cout << endl << "---------------------------------------------------------------------------------------" << endl;
temp = temp->next;
}
}
}
void LinkedList::addToHistory(string name , string shoes , string service , string time) {
// Adding data to the history
Node * temp = new Node; //Making a new node for the new data
temp->name = name;
temp->shoes = shoes;
temp->service = service;
temp->time = time;
if(head == NULL){
tail = temp;
temp->next = NULL;
temp->prev = NULL;
head = temp;
}
else{
temp->next = NULL;
temp->prev = tail;
tail->next = temp;
tail = temp;
}
}