Answered step by step
Verified Expert Solution
Question
1 Approved Answer
09.11 (The EvenNumber class) (The EvenNumber class) Define the EvenNumber class for representing an even number. The class contains: A data field value of the
09.11 (The EvenNumber class)
(The EvenNumber class) Define the EvenNumber class for representing an even number. The class contains:
- A data field value of the int type that represents the integer value stored in the object.
- A no-arg constructor that creates an EvenNumber object for the value 0.
- A constructor that constructs an EvenNumberobject with the specified value. (Note: If it is not an even number, add 1 to make it an even number.)
- A function named getValue() to return an intvalue for this object.
- A function named getNext() to return an EvenNumber object that represents the next even number after the current even number in this object.
- A function named getPrevious() to return an EvenNumber object that represents the previous even number before the current even number in this object.
Submit the following:
- Draw the UML diagram for the class, EvenNumber.
- Implement the class, EvenNumber.
- Write a test program that creates an EvenNumber object for value 16 and invokes the getNext() and getPrevious() functions to obtain and display these numbers. The program need not expect any input from the user. Also, test the constructor with value 5. Display its getNext() function.
language is C++
09.11 (The EvenNumber class)
(The EvenNumber class) Define the EvenNumber class for representing an even number. The class contains:
- A data field value of the int type that represents the integer value stored in the object.
- A no-arg constructor that creates an EvenNumber object for the value 0.
- A constructor that constructs an EvenNumberobject with the specified value. (Note: If it is not an even number, add 1 to make it an even number.)
- A function named getValue() to return an intvalue for this object.
- A function named getNext() to return an EvenNumber object that represents the next even number after the current even number in this object.
- A function named getPrevious() to return an EvenNumber object that represents the previous even number before the current even number in this object.
Submit the following:
- Draw the UML diagram for the class, EvenNumber.
- Implement the class, EvenNumber.
- Write a test program that creates an EvenNumber object for value 16 and invokes the getNext() and getPrevious() functions to obtain and display these numbers. The program need not expect any input from the user. Also, test the constructor with value 5. Display its getNext() function.
language is C++
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started