g to input the numbers I want instead. Like in main insetad of inputting the numbers myself, I wouldn't have to input the numbers after running the code because I would input them in the code before. Or is there a way I can create a test code to test certain dates first that are pre determined and I don't have to enter them? Here

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

can you help me please. this is my intital code but is there a way i can have set dates to be tested rather than me having to input the numbers I want instead. Like in main insetad of inputting the numbers myself, I wouldn't have to input the numbers after running the code because I would input them in the code before. Or is there a way I can create a test code to test certain dates first that are pre determined and I don't have to enter them? Here is my code below:

#include<iostream> 
using namespace std; 

class dateType 
private: 
    int dM; 
    int dD; 
    int dY; 
public:
    void setDate(int myMonth, int myDay, int myYear); 
    int getDay() const; 
    int getMonth() const; 
    int getYear() const; 
    void printDate() const; 
    bool isLeapYear(int myYear) ; 
    dateType (int myMonth=0,int myDay=0,int myYear=0); 
};

void dateType::setDate (int myMonth, int myDay, int myYear)
{
    int none; 
    if (myYear>0) 
    { 
        dY=myYear; 
        if (myMonth<=12) 
        {         
            dM=myMonth ; 
            switch (myMonth) 
            { 
                case 1: 
                case 3: 
                case 5: 
                case 7: 
                case 8: 
                case 10: 
                case 12:    none=31; 
                            break; 
                case 4: 
                case 6: 
                case 9: 
                case 11:    none=31;
                            break;
                case 2:     if (isLeapYear (myYear) ) 
                                none=29; 
                            else 
                            none=28; 
            } 
            if (myDay<=none) 
            { 
                dD=myDay; 
            }
            else 
            { 
                cout<<"The day you entered is not correct"<<endl; 
                dD=0; 
            }
        }
        else 
        { 
            cout<<"The month you entered is not correct"<<endl; 
            dM=0; 
        }
    }
    else 
    {
        cout<<"The year you entered is not correct"<<endl; 
        dY=0; 
    }
}


bool dateType::isLeapYear(int myYear) 
    
    if(myYear%4==0) 
        return true; 
    else 
        return false; 

void dateType::printDate()const 
    cout<<dM<<"-"<<dD<<"-"<<dY; 
}

int dateType::getMonth() const 
    return dM; 

int dateType::getDay() const 
    return dD; 

int dateType::getYear() const 
    return dY; 

dateType::dateType (int myMonth, int myDay, int myYear) 
    dM=myMonth; 
    dD=myDay; 
    dY=myYear; 

int main()
{
    int m,d,y,n; 
    dateType date(0,0,0); 
     
    cout<<"Please input the month number you would like: "; 
    cin>>m; 
    cout<<"Please input the day number you would like: "; 
    cin>>d; 
    cout<<"Please input the year you would like: "; 
    cin>>y; 
    cout << "Please input the date number: ";
    cin >> n;
    cout << "Date #" << n<<":" <<m<<"-"<<d<<"-"<< y << endl;
    date.setDate(m,d,y); 
    bool check =date.isLeapYear(y); 
    if(check) 
        cout<<"this is a leap year!:"; 
}
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

How do I set up my code to be tested if I am supposed to test it like this?  

TEST(Date, 1) {

dateType date1(3, 15, 2008);

testing::internal::CaptureStdout();

// output date1.printDate();

std::string output = testing::internal::GetCapturedStdout();

ASSERT_TRUE(output == "3-15-2008");

ASSERT_TRUE(date1.isLeapYear()); }

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Table
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