Question
Instructions In visual studio C++, Design and implement a class dayType that implements the day of the week in a program. The class dayType should
Instructions
In visual studio C++, Design and implement a class dayType that implements the day of the week in a program. The class dayType should store a day of the week, such as Sun for Sunday, Mon for Monday, etc. The program should be able to perform the following operations on an object of type dayType:
a. Set the day.
b. Print the day.
c. Return the day.
d. Return the next day.
e. Return the previous day.
f. Calculate and return the day by adding certain days to the current day. For example, if the current day is Monday and we add 4 days, the day to be returned is Friday. Similarly, if today is Tuesday and we add 13 days, the day to be returned is Monday.
g. Add the appropriate constructors.
g.1. No argument constructor.
g.2. Constructor with an integer input argument which initializes the day of the week.
g.3. Constructor with a string input argument which initializes the day of the week.
h. Add the appropriate destructor (which prints "dayType object destroyed").
Notes
Inside the class, store the day of the week as a number (0..6) where 0 is Monday and 6 is Sunday. Initialize the day of the week as 0 with an inline initialization.
When returning the day of the week, previous, or next; return a String such as Mon, Tue, Wed, Thu, Fri, Sat, Sun.
In the main
Create a dayType object and set a day of the week. Print this day of the week.
Create a second dayType object and copy the data from the first dayType object (e.g. obj2=obj1). Then, print the previous day.
Create a third dayType object and copy the data from the first dayType object. Then, print the next day.
Create a fourth dayType object and copy the data from the first dayType object. Then, return the day of the week after adding 11 days to the current day.
Files to submit
- dayType.h, dayType.cpp
- main program (.cpp)
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