Exercise on class inheritance in C++. General requirements: • All data members must be declared as “private” • No global variable is allowed to be declared and used (constants are ok) • Methods within the class and the requested functions cannot have “cin” or “cout” but it should make use of parameters and return value instead unless it is stated explicitly. • “cin” and “cout” should be used in main() or any testing functions • Please make sure that you clearly show how the C++ class, its methods and all the functions are being called and print out its return value and its results properly Please answer the following questions. 1. Define a class named “BooleanVariable” 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: - toString() method that can return a string in the following format: variable-name(variable-boolean-value) such as isSuccessful(true) - contains() 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.
Exercise on class inheritance in C++. General requirements: • All data members must be declared as “private” • No global variable is allowed to be declared and used (constants are ok) • Methods within the class and the requested functions cannot have “cin” or “cout” but it should make use of parameters and return value instead unless it is stated explicitly. • “cin” and “cout” should be used in main() or any testing functions • Please make sure that you clearly show how the C++ class, its methods and all the functions are being called and print out its return value and its results properly Please answer the following questions. 1. Define a class named “BooleanVariable” 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: - toString() method that can return a string in the following format: variable-name(variable-boolean-value) such as isSuccessful(true) - contains() 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.
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
Question
Exercise on class inheritance in C++.
General requirements:
• All data members must be declared as “private”
• No global variable is allowed to be declared and used (constants are ok)
• Methods within the class and the requested functions cannot have “cin” or “cout” but it should make use of parameters and return value instead unless it is stated explicitly.
• “cin” and “cout” should be used in main() or any testing functions
• Please make sure that you clearly show how the C++ class, its methods and all the functions are being called and print out its return value and its results properly
Please answer the following questions.
1. Define a class named “BooleanVariable” 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:
- toString() method that can return a string in the following format:
variable-name(variable-boolean-value) such as isSuccessful(true)
- contains() 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. Write a new class named “IntegerVariable” that must inherit from the “BooleanVariable” 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:
- toString() method that can return a string in the following format:
variable-name(variable-integer-value) such as count(100)
- isGreater() method that accepts another IntegerVariable object and returns true if its own integer value is greater than the integer value of the given object and false otherwise.
Show how this class being used to create objects and call all its methods and show how they work.
3. Write a function named “contains” that accepts a
4. Write a function named “createNewVariable” that will read in the variable name and a value (either “true” or “false” or an integer) from the user and create a dynamic BooleanVariable or IntegerVariable object (using new) depending the value that the user entered and return its pointer. You can assume the user will enter “true” or “false” or correct integer value. No error handling for the value is required.
Please note that this function can use cin and cout.
Please note that this function can use cin and cout.
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 2 steps with 1 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