Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ class ItemList { private: struct ListNode { int value; ListNode * next; }; ListNode * head; public: ItemList(); // Post: List is the empty

C++

class ItemList

{

private:

struct ListNode

{

int value;

ListNode * next;

};

ListNode * head;

public:

ItemList();

// Post: List is the empty list.

bool IsThere(int item) const;

// Post: If item is in the list IsThere is

// True; False, otherwise.

void Insert(int item);

// Pre: item is not already in the list.

// Post: item is in the list.

void Delete(int item);

// Pre: item is in the list.

// Post: item is no longer in the list.

void Print() const;

// Post: Items on the list are printed on the screen.

int GetLength() const;

// Post: Length is equal to the number of items in the

// list.

~ItemList();

// Post: List has been destroyed.

};

Just need some help with excersie 2 and 3 please!!

Exercise 2: Write a driver program that reads values from file int.dat, inserts them into the list, print the length of the final list, and prints the items. Be sure that your driver checks for the preconditions on the member functions of class ItemList before calling them. How many items are in the list? If your answer is not 11, your driver did not adhere to the preconditions. Correct your driver and return your program.

Exercise 3: Add code to your driver to test the remaining member functions. Delete -47, 1926, and 2000 and print the list to confirm that they are gone.

Output

image text in transcribed

1492 is not in the list 776 is not in the list 860 is not in the list 23 is not in the list 1698 is not in the list 935 is not in the list 1926 is not in the list 953 is not in the list 1960 is not in the list 1492 is already in the list 1776 is already in the list 1860 is already in the list 23 is already in the list 1698 is already in the list 000 is not in the list 935 is already in the list 1926 is already in the list 953 is already in the list L960 is already in the list -4? is not in the list There are 11 items in the list. -47 23 1492 698 776 860 1926 1935 1953 1960 2000 After deletion, there are 8 itens in the list. 23 1492 698 776 1860 935 1953 960 Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions

Question

3. You can gain power by making others feel important.

Answered: 1 week ago