Design and code a class in C++ that represents a single month of the year. It should have a single integer-typed data member to represent the month. Make sure to provide proper construction, access, and mutation for this member as well as input and output methods. In addition, methods for comparing two months chronologically for ordering would be useful as would a method to advance to the next month (note that January follows December and begins the cycle anew) or previous month. In fact, thinking about it, it might be good to be able to advance to a month an arbitrary number of whole months in the future or past: January '+' 5 = June; March '-' 5 = October. Place your Month class in a library. Write a test application (driver) for your class. Oh, and the programmers who commissioned this class wanted to make sure it could handle not only integer-valued representation of a Month but also either whole-word names or three-letter abbreviations for the Months. That means that they should be able to construct a Month object from either an integer value or a string -- which could be either the whole month name or a 3-letter version there-of. Similarly, they'd like to be able to retrieve the Month's information as either an integer value or a string (of either form), mutate the Month by any of these means, display by any of the three forms, and even allow their user to enter any of the three forms at the console. But, to keep things as simple as possible, they'd not like a whole lot of different names to remember. Please use the following names for all functions that perform such tasks: set_month, get_month, input, output, advance, before, after, same. (There may be only one of some methods, but others may need at least two methods to offer all requested functionality.)

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
icon
Related questions
Question

Design and code a class in C++ that represents a single month of the year. It should have a single integer-typed data member to represent the month. Make sure to provide proper construction, access, and mutation for this member as well as input and output methods. In addition, methods for comparing two months chronologically for ordering would be useful as would a method to advance to the next month (note that January follows December and begins the cycle anew) or previous month. In fact, thinking about it, it might be good to be able to advance to a month an arbitrary number of whole months in the future or past: January '+' 5 = June; March '-' 5 = October.

Place your Month class in a library.

Write a test application (driver) for your class.

Oh, and the programmers who commissioned this class wanted to make sure it could handle not only integer-valued representation of a Month but also either whole-word names or three-letter abbreviations for the Months. That means that they should be able to construct a Month object from either an integer value or a string -- which could be either the whole month name or a 3-letter version there-of.

Similarly, they'd like to be able to retrieve the Month's information as either an integer value or a string (of either form), mutate the Month by any of these means, display by any of the three forms, and even allow their user to enter any of the three forms at the console.

But, to keep things as simple as possible, they'd not like a whole lot of different names to remember. Please use the following names for all functions that perform such tasks: set_month, get_month, input, output, advance, before, after, same. (There may be only one of some methods, but others may need at least two methods to offer all requested functionality.)

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Data members
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
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education