We will be working on a project that designs a class calendarType, so that a client program can use this class to print a calendar for any month starting Jan 1. 1900. An example of the calendar for September 2019 is:                                  September 2019  Sun     Mon     Tue     Wed     Thu     Fri     Sat      1         2          3          4          5        6        7       8        9         10         11       12       13      14    15      16        17        18        19      20      21 22     23        24         25        26      27      28  29     30       31 We will develop several classes which will work together to create a calendar. The first of these classes is called dayType which will manipulate a day of the week. The class dayType will store a day, such as Sun for Sunday. The class 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. Include the appropriate constructors. the UML diagram for the dayType class looks like this:

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

dayType Class

We will be working on a project that designs a class calendarType, so that a client program can use this class to print a calendar for any month starting Jan 1. 1900.

An example of the calendar for September 2019 is:

                                 September 2019 

Sun     Mon     Tue     Wed     Thu     Fri     Sat    

 1         2          3          4          5        6        7     

 8        9         10         11       12       13      14   

15      16        17        18        19      20      21

22     23        24         25        26      27      28 

29     30       31

We will develop several classes which will work together to create a calendar. The first of these classes is called dayType which will manipulate a day of the week. The class dayType will store a day, such as Sun for Sunday. The class 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. Include the appropriate constructors.

the UML diagram for the dayType class looks like this:

          dayType 

-weekDay: string

-daaysOfWeek[7]:string

+print():void +nextDay():string +prevDay():string +addDay(int nDays):void +setDay(string d):void +getDay():string +dayType(string=“Sunday”)

 

The class has a static array to hold the names of the days of the week. Non-static class features (attributes or operations) belong to individual instances of the class (i.e., to an object). Static features belong to the class. Unless otherwise specified, features in a UML class diagram are non-static. The UML diagram denotes static features by underlining the feature.

The constructor uses default parameters so it can serve as the default constructor or as a constructor with parameters.

The header file has been supplied for you. Note the comments in the header file describing the preconditions and post condition for the member functions.

The implementation file is also included and shows how to initialize the static array. You are to complete the implementation file and write a client program to test the class. The client program should do the following:

1. Create a day object using the default constructor and use the print function to display the instance variable. The output should be “Sunday”.

2. Call prevDay() and print. The output should be “Saturday”.

3. Call nextDay() and print. The output should be “Monday”.

4. Create a day object using the constructor with parameters and initialize the object to “Monday”.

5. Use getDay() to display the value of the instance variable (should be “Monday”).

6. Using the second object, call addDays(3) and display the return value (should be “Thursday”).

7. . Use the second object to call addDays(5) and display the return value (should be “Tuesday”).

Label your output so that the user (i.e., me, your instructor) can tell what your program is doing. This client program will serve as your test to ensure that the class is working as it is supposed to. Here is an example of the labeled output:

 

> clang++-7 -pthread -std=c++17 -o main dayType.cpp main.cpp
> ./main
From default constructor: Sunday
Next day: Monday
Previous day: Saturday
From constructor with parameters: Monday
After adding 3 days: Thursday
After adding 5 days: Tuesday
Transcribed Image Text:> clang++-7 -pthread -std=c++17 -o main dayType.cpp main.cpp > ./main From default constructor: Sunday Next day: Monday Previous day: Saturday From constructor with parameters: Monday After adding 3 days: Thursday After adding 5 days: Tuesday
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Adjacency Matrix
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
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