Concept explainers
Inventory Bin Stack
Design an inventory class that stores the following members:
serialNum: An integer that holds a part’s serial number.
manufactDate: A member that holds the date the part was manufactured.
lotNum: An integer that holds the part’s lot number.
The class should have appropriate member functions for storing data into, and retrieving data from, these members.
Next, design a stack class that can hold objects of the class described above. If you wish, you may use the template you designed in
Last, design a program that uses the stack class described above. The program should have a loop that asks the user if he or she wishes to add a part to inventory, or take a part from inventory. The loop should repeat until the user is finished.
If the user wishes to add a part to inventory, the program should ask for the serial number, date of manufacture, and lot number. The data should be stored in an inventory object, and pushed onto the stack.
If the user wishes to take a part from inventory, the program should pop the top-most part from the stack and display the contents of its member variables.
When the user finishes the program, it should display the contents of the member values of all the objects that remain on the stack.
Want to see the full answer?
Check out a sample textbook solutionChapter 18 Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Additional Engineering Textbook Solutions
C Programming Language
Starting Out with Programming Logic and Design (4th Edition)
Database Concepts (8th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Starting Out With Visual Basic (8th Edition)
Problem Solving with C++ (10th Edition)
- Object Oriented Programming C++ Write a program that defines a class with a data member to holds a “serial number” for each object created from the class. That is, the first object created will be numbered 1, the second 2, and so on. To do this, you’ll need another data member that records a count of how many objects have been created so far. (This member should apply to the class as a whole; not to individual objects. What keyword specifies this?) Then, as each object is created, its constructor can examine this count member variable to determine the appropriate serial number for the new object. Add a member function that permits an object to report its own serial number. Then write a main() program that creates three objects and queries each about its serial number. They should respond I am object number 2, and so on.arrow_forwardC++ Data Structure:Create an AVL Tree C++ class that works similarly to std::map, but does NOT use std::map. In the private section, any members or methods may be modified in any way. Standard pointers or unique pointers may be used. #ifndef avltree_h#define avltree_h #include <memory> template <typename Key, typename Value=Key> class AVL_Tree { public: classNode { private: Key k; Value v; int bf; //balace factor std::unique_ptr<Node> left_, right_; Node(const Key& key) : k(key), bf(0) {} Node(const Key& key, const Value& value) : k(key), v(value), bf(0) {} public: Node *left() { return left_.get(); } Node *right() { return right_.get(); } const Key& key() const { return k; } const Value& value() const { return v; } const int balance_factor() const { eturn bf; }…arrow_forwardCourse: Data Structure and Algorithims Language: Java Kindly make the program in 2 hours. Task is well explained. You have to make the proogram properly in Java: Restriction: Prototype cannot be change you have to make program by using given prototype. TAsk: Create a class Node having two data members int data; Node next; Write the parametrized constructor of the class Node which contain one parameter int value assign this value to data and assign next to null Create class LinkList having one data members of type Node. Node head Write the following function in the LinkList class publicvoidinsertAtLast(int data);//this function add node at the end of the list publicvoid insertAthead(int data);//this function add node at the head of the list publicvoid deleteNode(int key);//this function find a node containing "key" and delete it publicvoid printLinkList();//this function print all the values in the Linklist public LinkListmergeList(LinkList l1,LinkList l2);// this function…arrow_forward
- Data structure & Algorithum java program 1) Add a constructor to the class "AList" that creates a list from a given array of objects.2) Add a method "getPosition" to the "AList" class that returns the position of a given object in the list. The header of the method is as follows : public int getPosition(T anObject)3) Write a program that thoroughly tests all the methods in the class "AList".4) Include comments to all source code.arrow_forwardBookstore class uses a dynamic array to hold names book titles. class BookStore { public: BookStore (); BookStore (const Bookstore & b); // POST: object made from b -BookStore (); void insert(string title); // POST: add title to the end of the titles list private: string store; int capacity; int size; }; Describe two different situations in which the copy constructor function is called. Write a short code snippet illustrating each situation. Explain the problem if this class did not provide a deep copy constructor function. // POST: empty object with room for 10 titles // POST: object is destructed // pointer to dynamic array of book titles // capacity of array // number of books used in the bookstorearrow_forwardInstructions: Turn all instances of classes into pointers. You will also need to combine the player and vector into one vector objects and fix all issues this causes. #ifndef ITEM_H #define ITEM_H class Item { public: Item() {}; enum class Type { sword, armor, shield, numTypes }; Item(Type classification, int bonusValue); Type getClassification() const; int getBonusValue() const; private: Type classification{ Type::numTypes }; int bonusValue{ 0 }; }; std::ostream& operator<< (std::ostream& o, const Item& src); bool operator< (const Item& srcL, const Item& srcR); int& operator+=(int& srcL, const Item& srcR); #endif // !ITEM_H #ifndef MONSTER_H #define MONSTER_H #include "Object.h" class Player; class Monster : public Object { public: Monster() {}; Monster(const Player& player); void update(Player& player, std::vector& monsters) override; int attack() const override; void defend(int damage) override; void print(std::ostream& o)…arrow_forward
- // CONSTANT// static const int MAX_SIZE = ____// IntSet::MAX_SIZE is the highest # of elements an IntSet// can accommodate.// CONSTRUCTOR// IntSet()// Pre: (none)// Post: The invoking IntSet is initialized to an empty// IntSet (i.e., one containing no relevant elements).// CONSTANT MEMBER FUNCTIONS (ACCESSORS)// int size() const// Pre: (none)// Post: Number of elements in the invoking IntSet is returned.// bool isEmpty() const// Pre: (none)// Post: True is returned if the invoking IntSet has no relevant// relevant elements, otherwise false is returned.// bool contains(int anInt) const// Pre: (none)// Post: true is returned if the invoking IntSet has anInt as an// element, otherwise false is returned.// bool isSubsetOf(const IntSet& otherIntSet) const// Pre: (none)// Post: True is returned if all elements of the invoking IntSet// are also elements of otherIntSet, otherwise false…arrow_forwardTrue or False Objects that are instances of a class can be stored in an array.arrow_forwardC# Write a console app that sets up a dictionary of Books in a Library. The dictionary is indexed by ISBN. Each bookstored in the dictionary is a Book object that stores Title and Author. The Book class should be a simple entityclass containing the Title, Author, and ISBN.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning