Question
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started