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.
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
Related questions
Concept explainers
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Question
100%
C++ (C plusplus)

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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images

Knowledge Booster
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
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education