Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
9th Edition
ISBN: 9780134498379
Author: Tony Gaddis
Publisher: PEARSON
Question
Book Icon
Chapter 19, Problem 13PC
Program Plan Intro

Inventory Bin Queue

Program Plan:

InventoryItem.h:

  • Include required header files
  • Declare a class named “InventoryItem”. Inside the class,
    • Inside “private” access specifier,
      • Declare variables “serialNum”, “manufactDate”, and “lotNum”.
    • Inside “public” access specifier,
      • Give definition for default constructor.
      • Give definition for overloaded constructor.
      • Give mutator function “set_SerialNum ()” to set serial number.
      • Give mutator function “set_ManufactDate ()” to set date.
      • Give mutator function “set_LotNum ()” to set lot number.
      • Give accessor function “get_SerialNum ()” that returns serial number.
      • Give accessor function “get_ManufactDate ()” that returns date.
      • Give accessor function “get_LotNum ()” that returns lot number.

Dynqueue.h:

  • Include required header files.
  • Create template class
  • Declare a class named “Dynqueue”. Inside the class,
    • Inside the “private” access specifier,
      • Create a structure named “QueueNode”.
        • Create an object for the template
        • Create a pointer named “next”.
      • Create two pointers named “front” and “rear”.
    • Inside “public” access specifier,
      • Declare constructor and destructor.
      • Declare the functions “enqueue ()”, “dequeue ()”, “isEmpty ()”, “isFull ()”, and “clear ()”.
  • Declare template class.
  • Give definition for the constructor.
    • Assign the values.
  • Declare template class.
  • Give definition for the destructor.
    • Call the function “clear ()”.
  • Declare template class.
  • Give function definition for “enqueue ()”.
    • Make the pointer “newNode” as null.
    • Assign “num” to newNode->value.
    • Make newNode->next as null.
    • Check whether the queue is empty using “isEmpty ()” function.
      • If the condition is true then, assign newNode to “front” and “rear”.
      • If the condition is not true then,
        • Assign newNode to rear->next
        • Assign newNode to “rear”.
      • Increment the variable “numItems”.
  • Declare template class.
  • Give function definition for “dequeue ()”.
    • Assign temp pointer as null.
    • Check if the queue is empty using “isEmpty()” function.
      • If the condition is true then print “The queue is empty”.
      • If the condition is not true then,
        • Assign the value of front to the variable “num”.
        • Make front->next as “temp”.
        • Delete the front value
        • Make temp as front.
        • Decrement the variable “numItems”.
  • Declare template class.
  • Give function definition for “isEmpty ()”.
    • Assign “true” to a Boolean variable
    • Check if “numItems” is true.
      • If the condition is true then assign “false” to the variable.
    • Return the Boolean variable.
  • Declare template class.
  • Give function definition for “clear ()”.
    • Create an object for template.
      • Dequeue values from queue till the queue becomes empty using “while” condition.

Main.cpp:

  • Include required header files
  • Inside “main ()” function,
    • Create a template for queue.
    • Create an object for the class
    • Declare variables “choice”, “serial”, and “mDate”.
    • Print the menu to the user till the user enters corresponding menu number using “while” condition.
    • Switch to case.
      • Case1:
        • Get the serial number and manufacturing date from the user.
        • Push the object into the queue using the function “enqueue ()”.
      • Case 2:
        • Check if the queue is empty using “isEmpty ()” function.
        • If the queue is not empty,
          • Dequeue an element which is inserted first.
          • Print the serial number and date that has been removed.
      • Case 3:
        • Exit

Blurred answer
Students have asked these similar questions
ASSUMING C LANGUAGE True or False: You can have the data portion of a Linked List be a Struct containing a Linked List itself
Com Please solve in Dart Programming Language   Traverse a collection with help of an iterator or list type object    Use a Queue as collection and also use the move next function to traverse    Solve it in the Dart. and don't forget to add the output  otherwise I willl downvote the solution
Stacks and Queues are called data structures because their operations are specialized.

Chapter 19 Solutions

Starting Out with C++ from Control Structures to Objects (9th Edition)

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning