Please answer the following questions. 1. Define a class named "BoolVariable" that manages a variable name (string) and a boolean value (true or false). It should not have default constructor. The class must at least provide the following methods: o toString() method that can return a string in the following format: variable-name(variable-boolean-value) such as isSuccessful(true) o containsIgnoreCase() that accepts a search string and it will return true if its variable name contains that string (case-insensitive) and false otherwise. Show how this class being used to create objects and call all its methods and show how they work.
Please answer the following questions. 1. Define a class named "BoolVariable" that manages a variable name (string) and a boolean value (true or false). It should not have default constructor. The class must at least provide the following methods: o toString() method that can return a string in the following format: variable-name(variable-boolean-value) such as isSuccessful(true) o containsIgnoreCase() that accepts a search string and it will return true if its variable name contains that string (case-insensitive) and false otherwise. Show how this class being used to create objects and call all its methods and show how they work.
Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter10: Object-oriented Programming
Section: Chapter Questions
Problem 7RQ
Related questions
Question
C++
Question 3:
![Please answer the following questions.
1. Define a class named "BoolVariable" that manages a variable name (string)
and a boolean value (true or false). It should not have default constructor.
The class must at least provide the following methods:
o toString() method that can return a string in the following format:
variable-name(variable-boolean-value) such as isSuccessful(true)
o containsIgnoreCase() that accepts a search string and it will return true if
its variable name contains that string (case-insensitive) and false
otherwise.
Show how this class being used to create objects and call all its methods and show
how they work.
2. Define a new exception class named "VarNameException" that must inherit
from the C++ runtime error class. This class will capture the error case for a
variable name when it is empty, only blanks or starting with a number.
For example, if the user tries to create with a variable name of ",
"Iname", it will generate an exception and this class should capture the reason
and the error value.
*, or
3. Write a new class named "IntVariable" that must inherit from the
"BoolVariable" class. This class manages a variable name (string) and a value
(integer). Please note that this class must make use of inheritance.
The class must at least provide the following methods:
o toString() method that can return a string in the following format:
variable-name(variable-integer-value) such as count(100)
o isGreater() method that accepts another IntVariable object and returns true
if its own integer value is greater than the integer value of the given object
and false otherwise.
Its constructor will generate exception with the right error information
using the VarNameException class whenever it is given a variable name
that can be empty, all blanks or starting with a number.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F38978a2f-da5a-46f6-9158-53ddeeee684e%2F6e7e80ed-344e-45f2-bc2f-b7d11421efcb%2F3nopxd_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Please answer the following questions.
1. Define a class named "BoolVariable" that manages a variable name (string)
and a boolean value (true or false). It should not have default constructor.
The class must at least provide the following methods:
o toString() method that can return a string in the following format:
variable-name(variable-boolean-value) such as isSuccessful(true)
o containsIgnoreCase() that accepts a search string and it will return true if
its variable name contains that string (case-insensitive) and false
otherwise.
Show how this class being used to create objects and call all its methods and show
how they work.
2. Define a new exception class named "VarNameException" that must inherit
from the C++ runtime error class. This class will capture the error case for a
variable name when it is empty, only blanks or starting with a number.
For example, if the user tries to create with a variable name of ",
"Iname", it will generate an exception and this class should capture the reason
and the error value.
*, or
3. Write a new class named "IntVariable" that must inherit from the
"BoolVariable" class. This class manages a variable name (string) and a value
(integer). Please note that this class must make use of inheritance.
The class must at least provide the following methods:
o toString() method that can return a string in the following format:
variable-name(variable-integer-value) such as count(100)
o isGreater() method that accepts another IntVariable object and returns true
if its own integer value is greater than the integer value of the given object
and false otherwise.
Its constructor will generate exception with the right error information
using the VarNameException class whenever it is given a variable name
that can be empty, all blanks or starting with a number.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
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
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage