EBK STARTING OUT WITH C++
EBK STARTING OUT WITH C++
8th Edition
ISBN: 8220100794438
Author: GADDIS
Publisher: PEARSON
Question
Book Icon
Chapter 18, 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
We are considering the RSA encryption scheme. The involved numbers are small, so the communication is insecure.  Alice's public key (n,public_key) is (247,7). A code breaker manages to factories  247 = 13 x 19  Determine Alice's secret key. To solve the problem, you need not use the extended Euclid algorithm, but you may assume that her private key is one of the following numbers 31,35,55,59,77,89.
Consider the following Turing Machine (TM). Does the TM halt if it begins on the empty tape? If it halts, after how many steps? Does the TM halt if it begins on a tape that contains a single letter A followed by blanks? Justify your answer.
Pllleasassseee ssiiirrrr soolveee thissssss questionnnnnnn
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