Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help code in c++, the assignment starts below the dashed line ____________________________________________________ (Chrono.h) #ifndef CHRONO_H #define CHRONO_H #include std_lib_facilities.h namespace Chrono { enum class

please help code in c++, the assignment starts below the dashed line

____________________________________________________

(Chrono.h)

#ifndef CHRONO_H #define CHRONO_H

#include "std_lib_facilities.h"

namespace Chrono { enum class Month { jan=1, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec };

Month operator++(Month& m); // prefix increment operator Month operator+(const Month& m, int nMonths); // addition Month operator+=(Month& m, int nMonths);

class Date { public: class Invalid { }; // to throw as exception Date(int yy, Month mm, int dd); // check for valid date and initialize Date(); // default constructor // the default copy operations are fine // non modifying operations: int day() const { return d; } Month month() const { return m; } int year() const { return y;} // modifying operations: void add_day(); ///add one day private: int y; Month m; int d; bool is_valid(int y, Month m, int d); // true for valid date int nDays(Month m); //how many days in Month m? };

bool operator==(const Date& a , const Date& b); bool operator!=(const Date& a , const Date& b); ostream& operator<<(ostream& os, const Date& d); istream& operator>>(istream& is, Date& dd); } // Chrono

#endif

Implement the Date class as described in lecture and in the textbook.

  • The attached header file Chrono.h contains all of the declarations. You do not need to change it.
  • Define each operator and function specified in Chrono.h
    • The << and >> operators should have the format (year, month, day)
    • Your default constructor should create the date (2001, 1, 1)
    • Ensure that the Month addition operators wrap back around to January when they go past December
    • Ensure add_day correctly moves to the next year / month when it should
  • Write your definitions in a file named Chrono.cpp
    • Note: The following definitions do not need anything else added to them:
      • enum class Month
      • class Invalid
      • accessor functions for day, month, and year
  • I will unit test the rest of your definitions here
    • You do not need to upload main
  • Be sure to implement your definions inside namespace Chrono{...}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions

Question

How many multiples of 4 are there between 10 and 250?

Answered: 1 week ago

Question

How many three-digit numbers are divisible by 7?

Answered: 1 week ago