Design and implement a class for double link list

Assignment Help JAVA Programming
Reference no: EM132109294

In this project, you are asked to design and implement a class for double link list to hold integers:

- The class should be called DList, you also need a class called Node that contains an int as the data

- Node needs the following data:

int data; //the data held by the node Node* parent; //the parent of the Node Node* child; //the child of the Node

- Node needs the following public functions:
Node(int)// constructor to create a Node with the input int

int GetData(); // return the int held by the Node

- DList needs a head and tail, both should be pointers to Node, and initialized to NULL

- DList needs a default constructor (no parameter), a copy constructor (take const

- DList needs the following public functions:

void PushFront(int a); //create a Node containing a //and add it to the front of the list

void PushEnd(int a); //create a Node containing a //and add it to the end of the list

Node* PopFront(); //popping out the first Node of the list, //if the list is empty, return NULL

void PopEnd(); //popping out the last Node of the list, //if the list is empty, return NULL

DList & as input)

void PrintListForward(); //print every element from start to end //in one line separated by a space

void PrintListReverse(); //print every element from end to start //in one line separated by a space

2 Files to turn in:

You need to turn in four files in a tar.gz file: makefile, main.C, DList.C, DList.h. Among them, you need to use the main.C provided which you cannot modify at all.

DList.h declares the class DList and Node. You can make DList the friend of Node so it can access the private data of the Node.

3 Functions:

All member function and operator prototypes are declared in xArray.h, with necessary comments before each function. The following are major functions:

- PushBack function is the core of this project, and should be used by other functions if necessary (for example, it can be used by the += and >> operators). This function put the integer at the end of the array. Since the array may not have enough space to hold it, you need to grow the array if necessary.

- [ ] operator should check the boundary of data, if idx is not within the boundary, print error message and exit the program; otherwise, return data[idx];

- >> operator should read in an integer and put it at the end of the array.

main.C File

#include "DList.h" #include using namespace std; int main() { DList list; int i; //pust 10 numbers to the end for (i = 0; i < 10; i++) list.PushEnd(i); cout << "Print forward\n"; list.PrintListForward(); cout << "Print reverse\n"; list.PrintListReverse(); cout << "Pop front and print\n"; //print the list from the beginning Node* n = list.PopFront(); while ( n != NULL) { cout << n->GetData() << endl; n = list.PopFront(); } //pust 10 numbers to the front for (i = 0; i < 10; i++) list.PushFront(i); //test copy constructor DList* list2 = new DList(list); cout << "Pop end and print\n"; //print the list from the end n = list2->PopEnd(); while ( n != NULL) { cout << n->GetData() << endl; n = list2->PopEnd(); } return 0; }

Reference no: EM132109294

Questions Cloud

Develop for the operational manager of the indicated firm : ITECH1103- Big Data and Analytics - ANALYTIC REPORT - Write a description of the selected dataset and project, and its importance for the firm.
Build a gui that facilitates playing one round : Build a GUI (graphical user interface) that facilitates playing one round (13 hands).
Define the objects and their functions : The Launcher will fire a projectile at a target the Launcher is static, the projectile follows a linear path. The projectile has a known velocity.
Create a predator-prey simulation in a 2-d ecosystem : Create a Predator-Prey Simulation in a two-dimensional ecosystem based on agent-based modeling. The Predator and Prey will act as agents in an ecosystem in this
Design and implement a class for double link list : All member function and operator prototypes are declared in xArray.h, with necessary comments before each function.
Create a java application that grades a multiple choice quiz : Prompt the user to enter the number of questions for the quiz, then prompt the user to enter the answer key for each question. Use an array.
Create an inventory database for a manufacturing facility : This project asks to create an inventory database for a manufacturing facility in Access. You are free to create whatever type of facility you would like.
Prompts the user to enter two lists of integers : Write a program with class name StrictlyIdentical that prompts the user to enter two lists of integers of size 5 and displays .
Research center at federal reserve : The Research Center at Federal Reserve looks at one key variable for policy makers in setting interest rates to maintain stable inflation. What is that variable

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd