Question: In c++ Write a .h and .cpp file to implement the following UMLS as follows: 2.2.1 dLL The class is described according to the simple

In c++

Write a .h and .cpp file to implement the following UMLS as follows:

2.2.1 dLL

The class is described according to the simple UML diagram below:

dLL

-head: item*

-tail: item*

-size: int

----------------------------

+dLL()

+~dLL()

+getHead(): item*

+getTail(): item*

+push(newItem:item*):void

+pop():item*

+getItem(i:int):item*

+minNode():T

+getSize():int

+printList():void

The class variables are as follows:

head: The head pointer of the doubly linked list.

tail: The tail pointer of the doubly linked list.

size: The current size of the doubly linked list. This starts at 0 and increases as the

list grows in size.

The class methods are as follows:

dLL: The class constructor. It starts by setting the variables to null and 0 respec-

tively.

dLL: The class destructor. It will deallocate all of the memory in the class.

getHead: This returns the head pointer of the doubly linked list.

getTail: This returns the tail pointer of the doubly linked list.

push: This adds a new item to the doubly linked list, by adding it to the front of

the list.

pop: This returns the top item of the linked list. The item is returned and removed

from the list.

getItem: This returns the item of the linked list at the index specied by the

argument but without removing it from the list. If the index is out of bounds,

return null.

minNode: This returns the value of the item that has the lowest value in the linked

list.

getSize: This returns the current size of the linked list.

printList: This prints out the entire list in order, from head to tail. Each item's

data value is separate by a comma. For example: 3.1,5,26.6,17.3

2.2.2 item

The class is described according to the simple UML diagram below:

item

-data:T

-------------------

+item(t:T)

+~item()

+next: item*

+prev: item*

+getData():T

The class has the following variables:

data: A template variable that stores some piece of information.

next: A pointer of item type to the next item in the linked list.

prev: A pointer of item type to the previous item in the linked list.

The class has the following methods:

item: This constructor receives an argument and instantiates the data variable with

it.

item: This is the destructor for the item class. It prints out "Item Deleted" with

no quotation marks and a new line at the end.

getData: This returns the data element stored in the item.

You will be allowed to use the following libraries: cstdlib,string,iostream

Your submission must contain item.h,

item.cpp, dLL.cpp, dLL.h, main.cpp

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!