support@w4writers.com +44 7743 307695
Feb 27, 2024

Assignment Task

Objective

The objective of this Lab is to explore creating and using an ordered linked list.

Task

1.  Create an ordered double-linked list class.

  • Create a new project. You can name this whatever you like.
  • Design and implement an ordered linked list class as described in class. This class should be a template.  The template is expected to have overloaded the >, < and>
  • The class should have the following methods fully implemented.
  • Constructor
  • AddItem – adds an item from the list
  • GetItem – searches the list for the given item. If found, it removes it from the list and returns it.  If not found, it returns a null pointer.
  • IsInlist – returns a bool indicating if the given item is in the list.
  • Is Empty – returns a bool indicating if the list is empty.
  • Size – returns an int indicating the number of items in the list.
  • See Next – returns the item without removing it from the list at a given location in the list. The class will maintain the next location and will start at the first item in the list.  When it gets to the last item in the list, it will return a null pointer after it gets past the last item.  If the list is empty, this will throw an error.  2 calls to SeeNext will return the 2 items next to each other in the list unless SeeAt or Reset is called in between the 2 calls (or the first call returns the last item in the list).

See Prev – Same as SeeNext except in the other direction.

  1. See At – Finds an item at a location in the list (int passed in from user), and returns the item without removing it. If the location passed by the user is past the end of the list, this will throw an error.  This will set the location used by SeeNext to point at the item after the item returned.

  2. Reset – resets the location that the SeeNext function uses to point at the first item in the list.

  3. Destructor – make sure you remove all items to avoid memory leaks

  4. All items passed to or from the class should be done so via a pointer rather than by value.

  5. Make sure you don’t have any memory leaks.

2.  Create a class to be used as the item stored in the list. This class will be a part.  It should have the following members at a minimum.

1. Private

  • SKU – stock keeping number
  • Description
  • Price
  • UOM - Unit of measure (is it sold by the foot, pound, each, etc…)
  • QuantityOnHand
  • LeadTime (number of days it takes to order if there aren’t any on hand to sell)

2. Public

  • Constructor – This accepts parameters for SKU, Description, Price, and UOM. It has an optional parameter for QuantityOnHand which if missing is set to 0.
  • GetPartInfo – this returns a string containing both SKU concatenated with Description
  • GetPrice
  • InStock – returns a bool indicating if the Quantity On Hand is >0.
  • Available – accepts a date. This returns true if QuantityOnHand is >0. If it isn’t, it calculates if the desired date is > LeadTime (added to current date) and returns the results of that comparison
  • Overloads of the >, < and>

3. Create a test program that has a menu allowing you to test each of the functions in your linked last class (Task 1).

  • This should present the user with a choice of public member functions of your linked list class and ask which the user would like to try.
  • When the user selects a member function, the program will prompt the user for any required information. For example, the GetItem function only requires a SKU as that is what is being compared but the AddItem requires the user to enter a SKU, Description, Price, UOM and optionally a QuantityOnHand.
  • Test your program. Include a screen shot of some of this testing in your lab report.

4.  Create a visualization of your list using ASCII art.

  • Modify your part class to include a display method that will output to the screen the contents of the class.
  • This method should write directly to the screen.
  • This method does not need to display all members of the item, just key members (explain your choice of key members in your lab report).
  • This method should reuse members of the class as much as possible.

Modify your linked list class to add a new public method to display the list.

  1. This method should write directly to the screen.

  2. This method should walk through the list and display every item in the list on the screen. The format of the output is up to you.

  3. To display the contents of the item in the list, it should call the display member of the item (created in step 1 of this task).

  4. This method should reuse members of the class as much as possible.

  5. This method should not change the results of SeeNext method meaning it should not have a different value for the internal variable used by SeeNext after this method completes.

  6. Modify your test program from task 3 to include an option that calls this new method.

  7. Test your modifications. Include in your lab report a screen shot showing the results of this new method with at least 4 items in your list.

Recent Post

Order this Assignment now

Total: GBP120

fables template