/* * ---------------------------------------------------------------------------- * Course : COSC 1437 Programming Fundamentals II * Subject : Project II * Instructor : James Sasitorn * ---------------------------------------------------------------------------- */ Problem: Object Orientation Design +--------------------------------+ In this project, you are asked to design a user defined data type following object oriented principles for a number type. With this project, you will explore and implement the C++ language features in the area of inheritance class relationship, operators overloading, and polymorphism. The problem involves designing a User Defined Data Types (classes) for floating numbers representing the C++ primitive data type double and float, but you do so by adding multiple features to the classes. In most OOP languages, what is known as simple/basic/primitive data types in C++; such as, char, int, long, float, double, and so on, are objects. However, C++ lacks these features, but it doesn't prevent anyone from having one using classes and that is partly the purpose of this project. For practical purpose, we will limit ourselves to floating-point family; in other words, we need to design classes that represent only the float and double data types. Please look at the attached UML diagram; it is incomplete, but it should help. Suggested Design +-------------------------------+ 1. Have a superclass called Decimal for any number type. This class, at least, should include the following members. a. A double-data-type member variable called num. The access modifier for this member should be "protected". b. Constructor that receives a double value and assigns the member variable num c. Constructor that doesn't receives any value, but that initialize the member variable num to zero (0). d. Instance functions that includes i. Setters and getters functions ii. Functions that convert and return the value of the member variable num A) In binary B) In hexadecimal e. Static function A functions that returns a string form of the value of the member variable num 2. Create derived classes (subclasses) from Decimal that are called Float and Double. These classes are suppose to exhibit the behavior of float and double and provide rich features to perform arithmetic operations, conversion, and so on. a. Each subclass (Float and Double) must work with the superclass member variable "num". b. Each subclass must provides two constructors i. A constructor that receives a double value and assigns value to the member variable num. Remember, access to the variable "num" is granted through the inheritance relationship with Decimal class. ii. A constructor that doesn't receives any value, but that initialize the member variable num to zero (0). c. Setters and getters functions that are compliant to the size of float and double based on their respective classes. d. Operator Overloading functions supporting the following operators: i. Arithmetic operators: +, -, /, * ii. Relational operators: <, <=, >, >=, !=, == iii. I/O operators: <<, >> Additional Requirements +---------------------+ 1. A user interface with clear and understandable instruction including a friendly exit from the program. 2. Source code must be documented. 3. Source code must be formatted properly and consistently. 4. Submit the Source code by email and turned in Grading Outline +-----------------------+ Functionality / 60 Coding Style / 20 User Provided Tests / 10 Documentation / 10 --------------------------- Final Grade [ /100 ]