Hello. I'm trying to make a C++ program  practices with classes and OOP with dates, using three files: main.cpp, Date.cpp, and Date.h. I'm getting errors in main.pp for undefined references and in Date.cpp. there is alse an error for undefined reference Requirements Date.h will contain the class declaration. The following is required in the class declaration: The private attributes are the month, day, and year. The public member functions are PrintDate, SetDate, and NextDate The default constructor should initialize all data to the value 0. NextDate should still return a new Date object with the next day's information. This function needs to be completed (For this, just assume Feb has 29 days all the time even though it is not true.) Date.cpp will contain the implementation of all member functions and the constructor main.cpp* will need to be updated to use the member functions. Example:     SetDate(today,2,13,2016);     // today.month = 2;     // today.day   = 13;     // today.year  = 2016;     PrintDate(today);            // should print 2/13/16     tomorrow = NextDate(today);                       Becomes                       today.SetDate(2,13,2016);                       today.PrintDate();                       tomorrow = today.NextDate();   Date.h #ifndef DATE__H     /* To prevent multiple inclusion problems */ #define DATE__H class Date { private:     int month;     int day;     int year; public:   void SetDate(int mo, int da, int yr);   void PrintDate(Date date);   Date NextDate(Date date); }; #endif   Required Output: DateExample by student name 2/13/16 2/14/16 2/14/16 1/1/00 3/1/00 2/29/00 3/1/17 2/29/16 0/0/00

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

Hello. I'm trying to make a C++ program  practices with classes and OOP with dates, using three files: main.cpp, Date.cpp, and Date.h. I'm getting errors in main.pp for undefined references and in Date.cpp. there is alse an error for undefined reference

Requirements

  1. Date.h will contain the class declaration. The following is required in the class declaration:

    1. The private attributes are the month, day, and year.
    2. The public member functions are PrintDateSetDate, and NextDate
    3. The default constructor should initialize all data to the value 0.
    4. NextDate should still return a new Date object with the next day's information. This function needs to be completed (For this, just assume Feb has 29 days all the time even though it is not true.)
  2. Date.cpp will contain the implementation of all member functions and the constructor

  3. main.cpp* will need to be updated to use the member functions. Example:


    1.     SetDate(today,2,13,2016);
          // today.month = 2;
          // today.day   = 13;
          // today.year  = 2016;

          PrintDate(today);            // should print 2/13/16
          tomorrow = NextDate(today);

                      Becomes

                      today.SetDate(2,13,2016);
                      today.PrintDate();
                      tomorrow = today.NextDate();
 

Date.h

#ifndef DATE__H     /* To prevent multiple inclusion problems */
#define DATE__H

class Date
{
private:
    int month;
    int day;
    int year;

public:
  void SetDate(int mo, int da, int yr);
  void PrintDate(Date date);
  Date NextDate(Date date);
};

#endif

 

Required Output:

DateExample by student name
2/13/16
2/14/16
2/14/16
1/1/00
3/1/00
2/29/00
3/1/17
2/29/16
0/0/00

1 #include <iomanip>
2 #include <iostream>
3
4 #include "Date.h"
3
0
7 ✓ void Date::SetDate(int mo, int da, int yr) {
8
9
10
11
12
13
14
15
10
17
18
19 Date Date::NextDate(Date date) {
20
21
22
23
24
25
20
27
28
29
30-
31
32
33
34 v
35
30
37
38
39
40
939959
41
42
43
44
45
40
47
48
}
month = mo;
day = da;
year = yr;
void Date::PrintDate(Date date) {
std::cout<<date.month <<"/" <<date.day <<"/" << std::setfill('0')
<<< std::setw(2) <<date.year 100 << std::setfill(' ')
<<< std::endl;
}
}
Date newDate;
int monthEnd;
newDate= date;
newDate.day++;
// ... replace with remaining code
if (newDate.month == 2){
monthEnd = 29;
}
else if(newDate.month == 4 || newDate.month == 6 || newDate.month == 9 || newDate.month == 11){
//April, June, September, and November
monthEnd = 30;
}
else{
}
monthEnd = 31;
//check
if (newDate.day> monthEnd){ //If there was a 30 versus a 31 in 30 day month, then it would go to the next day and month
newDate.day = 1;
newDate.month++;
if (newDate.month > 12){ //if the number of month is greater than december, move to the next month in the new year
newDate.month = 1;
newDate.year++;
}
}
return newDate;
Transcribed Image Text:1 #include <iomanip> 2 #include <iostream> 3 4 #include "Date.h" 3 0 7 ✓ void Date::SetDate(int mo, int da, int yr) { 8 9 10 11 12 13 14 15 10 17 18 19 Date Date::NextDate(Date date) { 20 21 22 23 24 25 20 27 28 29 30- 31 32 33 34 v 35 30 37 38 39 40 939959 41 42 43 44 45 40 47 48 } month = mo; day = da; year = yr; void Date::PrintDate(Date date) { std::cout<<date.month <<"/" <<date.day <<"/" << std::setfill('0') <<< std::setw(2) <<date.year 100 << std::setfill(' ') <<< std::endl; } } Date newDate; int monthEnd; newDate= date; newDate.day++; // ... replace with remaining code if (newDate.month == 2){ monthEnd = 29; } else if(newDate.month == 4 || newDate.month == 6 || newDate.month == 9 || newDate.month == 11){ //April, June, September, and November monthEnd = 30; } else{ } monthEnd = 31; //check if (newDate.day> monthEnd){ //If there was a 30 versus a 31 in 30 day month, then it would go to the next day and month newDate.day = 1; newDate.month++; if (newDate.month > 12){ //if the number of month is greater than december, move to the next month in the new year newDate.month = 1; newDate.year++; } } return newDate;
3 #include <iostream>
#include <iomanip>
0
7
8 #include "Date.h"
9
10
11 int main()
12 {
13
14
15
10
17 //SetDate(today,2,13, 2010);
// today.month= 2;
// today.day = 13;
// today.year = 2010;
18
19
20
21
22
23
24
33
34
35
30
37
38
Date today, tomorrow, valentines day, no_date;
std::cout<<"DateExample by Rahma Seid\n";
23
20
27
28
29 today. SetDate(12, 31, 1999);
30 tomorrow.PrintDate( tomorrow);
31
32
today. SetDate(2, 13, 2010);
today.PrintDate(today);
tomorrow = today.NextDate(today);
45
40
47
48
49
50
31
52
// should print 2/13/10
tomorrow.PrintDate(tomorrow); // should print 2/14/10
valentines day = tomorrow;
today.PrintDate(valentines day); // should print 2/14/16
}
tomorrow = today. NextDate(today);
39 tomorrow.PrintDate( tomorrow);
40
today.SetDate(2, 28, 1900);
tomorrow.PrintDate( tomorrow); // should print 3/1/00
tomorrow = today.NextDate( today);
// should print 1/1/00
today.SetDate(2, 28, 2000);
tomorrow = today. NextDate(today);
41
today.SetDate(2, 28, 2017);
42 tomorrow = today. NextDate(today);
43 tomorrow.PrintDate( tomorrow);
today.SetDate(0, 0, 0000);
today.PrintDate(no_date);
// should print 2/29/00
return 0;
today.SetDate(2, 28, 2010);
tomorrow = today. NextDate(today);
tomorrow.PrintDate( tomorrow);
// should print 3/1/17
// should print 2/29/10
// should print 0/0/00
Transcribed Image Text:3 #include <iostream> #include <iomanip> 0 7 8 #include "Date.h" 9 10 11 int main() 12 { 13 14 15 10 17 //SetDate(today,2,13, 2010); // today.month= 2; // today.day = 13; // today.year = 2010; 18 19 20 21 22 23 24 33 34 35 30 37 38 Date today, tomorrow, valentines day, no_date; std::cout<<"DateExample by Rahma Seid\n"; 23 20 27 28 29 today. SetDate(12, 31, 1999); 30 tomorrow.PrintDate( tomorrow); 31 32 today. SetDate(2, 13, 2010); today.PrintDate(today); tomorrow = today.NextDate(today); 45 40 47 48 49 50 31 52 // should print 2/13/10 tomorrow.PrintDate(tomorrow); // should print 2/14/10 valentines day = tomorrow; today.PrintDate(valentines day); // should print 2/14/16 } tomorrow = today. NextDate(today); 39 tomorrow.PrintDate( tomorrow); 40 today.SetDate(2, 28, 1900); tomorrow.PrintDate( tomorrow); // should print 3/1/00 tomorrow = today.NextDate( today); // should print 1/1/00 today.SetDate(2, 28, 2000); tomorrow = today. NextDate(today); 41 today.SetDate(2, 28, 2017); 42 tomorrow = today. NextDate(today); 43 tomorrow.PrintDate( tomorrow); today.SetDate(0, 0, 0000); today.PrintDate(no_date); // should print 2/29/00 return 0; today.SetDate(2, 28, 2010); tomorrow = today. NextDate(today); tomorrow.PrintDate( tomorrow); // should print 3/1/17 // should print 2/29/10 // should print 0/0/00
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 8 steps with 4 images

Blurred answer
Knowledge Booster
ADT and Class
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