cis22c/04-dl-lists/ListNode.h

44 lines
1.1 KiB
C++

// Specification file for the ListNode class
// Written By: Iurii Tatishchev
// Reviewed & Modified by: Iurii Tatishchev
// IDE: CLion
#ifndef LISTNODE_H
#define LISTNODE_H
#include <iostream>
#include "Park.h"
class ListNode {
private:
Park data; // store data
ListNode *forw; // a pointer to the next node in the list
ListNode *back; // a pointer to the previous node in the list
public:
// Constructor
ListNode() { forw = back = nullptr; }
ListNode(const Park &dataIn, ListNode *forw = nullptr, ListNode *back = nullptr) {
data = dataIn;
this->forw = forw;
this->back = back;
}
// setters
// set the forw pointer
void setNext(ListNode *nextPtr) { forw = nextPtr; }
// set the back pointer
void setPrev(ListNode *prevPtr) { back = prevPtr; }
// getters
// return pointer in the next node
ListNode *getNext() const { return forw; }
// return pointer in the previous node
ListNode *getPrev() const { return back; }
// return data object in the listnode
Park& getData() { return data; }
};
#endif