Create a new project named lab7_1. You will be implementing a Tacos class. For the class attributes, let’s use to type of taco, number of tacos, and price. Note that the price per taco of any type is 99 cents. Therefore, allow the taco type and number of tacos to be set directly, but not the price! The price should be set automatically based on the number of tacos entered. So a good idea may be to call the setter for the price inside the function that sets the number of tacos. Some other requirements: A default constructor and a constructor with parameters for your taco type and number of tacos member variables. You should also include setters and getters for these private member variables. However, make sure that the setter for price is private! You don’t want anyone outside the class modifying price. This setter should be called anytime you change the number of tacos. Your constructor needs to call a set method that allows you to set the two member variables, thus takes two arguments. In turn, the set method will call the individual setters for each member variable. The number of tacos setter needs to throw an exception if a valid number for tacos is not used (only positive numbers should work). This means that back in your main, you will also have a try...catch block to catch this exception. Don’t forget to include the stdexcept library. Use a general run-time exception like shown before: if(some condition) do some stuff; else throw runtime_error("Error: No negative tacos!"); Which means the catch should be catching a runtime_error object from the main. You will also make use of the const keyword to indicate which methods are not modifying the object. Demonstrate the use of your Tacos class by creating objects of your class type, setting them to different values, and then printing out their information. Make sure to also show an example of an incorrect value being assigned to a member variable, and the program throwing an exception. Potential sample run: #include #include "Tacos.h" int main() { Tacos t1, t2, t3; t1.setTacos("carnitas", 1); t2.setTacos("asada", 3); t3.setTacos("pastor", 2); t1.print(); t2.print(); try { t2.setNumber(-4); } catch (runtime_error & e) { cout << "Error: " << e.what() << endl; } t3.print(); return 0; } 1 carnitas taco costs $0.99. 3 asada tacos costs $2.97. Error: No negative tacos! 2 pastor tacos costs $1.98.

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
Create a new project named lab7_1. You will be implementing a Tacos class. For the class attributes, let’s use to type of taco, number of tacos, and price. Note that the price per taco of any type is 99 cents. Therefore, allow the taco type and number of tacos to be set directly, but not the price! The price should be set automatically based on the number of tacos entered. So a good idea may be to call the setter for the price inside the function that sets the number of tacos. Some other requirements: A default constructor and a constructor with parameters for your taco type and number of tacos member variables. You should also include setters and getters for these private member variables. However, make sure that the setter for price is private! You don’t want anyone outside the class modifying price. This setter should be called anytime you change the number of tacos. Your constructor needs to call a set method that allows you to set the two member variables, thus takes two arguments. In turn, the set method will call the individual setters for each member variable. The number of tacos setter needs to throw an exception if a valid number for tacos is not used (only positive numbers should work). This means that back in your main, you will also have a try...catch block to catch this exception. Don’t forget to include the stdexcept library. Use a general run-time exception like shown before: if(some condition) do some stuff; else throw runtime_error("Error: No negative tacos!"); Which means the catch should be catching a runtime_error object from the main. You will also make use of the const keyword to indicate which methods are not modifying the object. Demonstrate the use of your Tacos class by creating objects of your class type, setting them to different values, and then printing out their information. Make sure to also show an example of an incorrect value being assigned to a member variable, and the program throwing an exception. Potential sample run: #include #include "Tacos.h" int main() { Tacos t1, t2, t3; t1.setTacos("carnitas", 1); t2.setTacos("asada", 3); t3.setTacos("pastor", 2); t1.print(); t2.print(); try { t2.setNumber(-4); } catch (runtime_error & e) { cout << "Error: " << e.what() << endl; } t3.print(); return 0; } 1 carnitas taco costs $0.99. 3 asada tacos costs $2.97. Error: No negative tacos! 2 pastor tacos costs $1.98.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Running Time of Application
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
  • SEE MORE 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