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

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Algebraic Expressions
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
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage