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

  You have to design and implement a simple and small email

helo i need your help in java assignment. i need solution asap. i have seen the same question on your website and even

  Write a program that determines the day of the week

You are to write a program that determines the day of the week for New Year's Day in the year 3000. To do this, you must create your own date class (MyDate) and use the following interface and main program.

  Complete the twins() method

Complete the twins() method, which takes an integer argument n and prints all the sets of twin primes that are less than n, one pair per line

  Write java program to print price of table-furniture company

Write down the Java program for furniture company. Ask user to select P for Pine, O for Oak or M for Mahogany. Illustrate the price of table produced with chosen wood.

  Prepare a class called geometrycalculator

Calculates the area of a circle of a given radius and write a class called GeometryCalculator that includes the subsequent methods

  Describing the career path of a java developer

Create a 2-3 page report covering the role of Java in industry today compared to C# and Objective-C. Your report should cover: What are the advantages and disadvantages of Java as compared to the other two?

  Describe the behavior of the java class

The authors initially describe the behavior of the java.util.Hashmap class. As they describe it, the Java implementation of a Hash Map consists of a table (bucket array) of entries. Each entry consists of a K, V pair with the addition of a next re..

  Accounts receivable system appication

A common business application is an 'Accounts Receivable' (AR) system. Companies use an AR system to bill their customers on sales of their products

  Implement security so that all users can view the informatio

Implement security so that all users can view the information about the projects, but only authenticated users

  Write a method called range that returns the range of value

Write a method called 'range' that returns the range of values in an array of integers. The range is defined as 1 more than the difference between the maximum and minimum values in the array. For example, if an array called list contains the value..

  Define a function name classify that takes a string as input

The function should return a string value, either "word" or "phrase", depending on whether the input string contains any spaces

  Design a class named cryptgram java with given requirements

Design a class Named CryptGram.java with given requirements: Data Members: a Letter array named orderedFrequency to store frequency of 26 alphabetic letters.

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