Your code should ensure that user inputs a valid choice (1..4) only If the user choses “1”, this should call a function called addNewAuto. This function will take the Inventory object as a parameter and then call the addAutomobile method to add the new car If the user choses “2”, this should call the displayInventory method of the Inventory object If the user choses “3”, this should call a function called searchAuto. This function will take the Inventory object as a parameter and then ask the user for the mileage. Then it will display all automobiles in the inventory below that mileage. If the user choses “4”, the system will exit.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Write a C++ program that does the following:

  • Create a class called Automobile
  • This class has the following private attributes:
    • model
    • year
    • mileage
  • This class has the following methods:
    • Default constructor
    • Non-default constructor that will initialize all the above attributes
    • Set/Get method for each of the above attributes
    • displayAuto that will print the information for the Automobile all three attributes on the same line with proper spacing
    • Destructor method that will print a message that the object has been deleted
  • Create a class called Inventory
  • This class has the following private attributes:
    • count: This represents how many current automobiles in the inventory
    • maxCount: This represents the maximum number of automobiles that can be stored
    • autoPtr: A pointer to Automobile objects.
  • This class has the following methods:
    • Default constructor (count is 0, maxCount will be 10, autoPtr is NULL)
    • Non-default constructor that will have one integer parameter
      • count will be initialized to 0
      • maxCount will be set to that one parameter passed
      • autoPtr will be allocated enough space to accommodate enough objects equals to the maxCount. Basically, you will use the new operator to allocate space for an array of Automobile objects.
    • addAutombile to append a new automobile to the inventory and update all the needed attributes. This method needs to check to see that you have not exceeded the capacity of the inventory
    • displayInventory method that will call displayAuto method to display the content of the inventory
    • Destructor method to make sure everything is cleaned up especially the memory allocated for the pointer. Also display a message that you called the destructor of the Inventory class.

 

  • Your main function should do the following
    • Ask the user how many automobiles to create
    • Define the appropriate variables as needed
    • Create an Inventory object and call the non-default constructor for that object with the number of automobiles given by the user
    •  Use a do..while loop to display the menu with the following options:
      • 1: Add an automobile to the inventory
      • 2: Display the content of the inventory
      • 3: Display the automobiles below certain mileage
      • 4: exit
    • Your code should ensure that user inputs a valid choice (1..4) only
    • If the user choses “1”, this should call a function called addNewAuto. This function will take the Inventory object as a parameter and then call the addAutomobile method to add the new car
    • If the user choses “2”, this should call the displayInventory method of the Inventory object
    • If the user choses “3”, this should call a function called searchAuto. This function will take the Inventory object as a parameter and then ask the user for the mileage. Then it will display all automobiles in the inventory below that mileage.
    • If the user choses “4”, the system will exit.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education