Given the following "Item" class #include class Item { public: virtual int virtual bool virtual bool virtual std::string toString() = 0; getId() = 0; isActive() = 0; isSame(Item & item) = 0; ; Please answer the following questions.

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%

C++ (C plusplus)

Please note that all defined classes must declare data members as private.
Given the following "Item" class
#include <string>
class Item
{
public:
virtual int
virtual bool
getId() = 0;
isActive() = 0;
virtual bool isSame(Item & item) = 0;
virtual std::string toString() = 0;
};
Please answer the following questions.
1. Define a new exception class named "InvalidItemException" that accepts a
reason code (integer) to describe the error: 1 (id cannot be negative), 2
(description cannot be empty).
2. Define a new class named "Event" that must derive from the given Item class.
This class manages Event info: id (integer), the description (string) and the status
(bool).
It will allow the Event info to be printed out as shown in the following examples:
ID(12345) DESC(Final Exam) STATUS(ACTIVE)
ID(12346) DESC(Winter Break) STATUS(ACTIVE)
ID(12347) DESC(Project) STATUS(INACTIVE)
This class must prevent the creation of the Event object when the id is negative or
the description is empty by generating an "InvalidItemException" error with the
proper reason code (1 or 2).
Two events are the same when only the event ids are the same.
3. Define a new class named "Holiday" that must inherit from the Event class. This
class manages Holiday info: id (integer) and the description (string) but its status
is always "ACTIVE". Its output example is
ID(12348) DESC(Christmas) STATUS(ACTIVE)
4. Write a function named "getOnly ActiveItems" that accepts a vector of Item
object pointers. It will go through the list and return the list of Item object pointers
(to Event or Holiday objects) with ACTIVE status.
5. Write the main program to demonstrate the usage of all the classes and methods
that you have written:
Create and print out Event and Holiday objects
Compare them using "isSame" methods
Handle exceptions for both invalid id and empty description by checking the
reason code and printing out the corresponding error message.
Call getOnly ActiveItems method with the list of mixed Event and Holiday
objects.
Transcribed Image Text:Please note that all defined classes must declare data members as private. Given the following "Item" class #include <string> class Item { public: virtual int virtual bool getId() = 0; isActive() = 0; virtual bool isSame(Item & item) = 0; virtual std::string toString() = 0; }; Please answer the following questions. 1. Define a new exception class named "InvalidItemException" that accepts a reason code (integer) to describe the error: 1 (id cannot be negative), 2 (description cannot be empty). 2. Define a new class named "Event" that must derive from the given Item class. This class manages Event info: id (integer), the description (string) and the status (bool). It will allow the Event info to be printed out as shown in the following examples: ID(12345) DESC(Final Exam) STATUS(ACTIVE) ID(12346) DESC(Winter Break) STATUS(ACTIVE) ID(12347) DESC(Project) STATUS(INACTIVE) This class must prevent the creation of the Event object when the id is negative or the description is empty by generating an "InvalidItemException" error with the proper reason code (1 or 2). Two events are the same when only the event ids are the same. 3. Define a new class named "Holiday" that must inherit from the Event class. This class manages Holiday info: id (integer) and the description (string) but its status is always "ACTIVE". Its output example is ID(12348) DESC(Christmas) STATUS(ACTIVE) 4. Write a function named "getOnly ActiveItems" that accepts a vector of Item object pointers. It will go through the list and return the list of Item object pointers (to Event or Holiday objects) with ACTIVE status. 5. Write the main program to demonstrate the usage of all the classes and methods that you have written: Create and print out Event and Holiday objects Compare them using "isSame" methods Handle exceptions for both invalid id and empty description by checking the reason code and printing out the corresponding error message. Call getOnly ActiveItems method with the list of mixed Event and Holiday objects.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

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.
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