Question: I have a nice question, here is my task. As stated below, modifying Date.h and Main.cpp is strictly prohibited. All you have to do is

I have a nice question, here is my task. As stated below, modifying Date.h and Main.cpp is strictly prohibited. All you have to do is writing up a code, which is Date.cpp, within the rules of the text below. Codes are provided below.

+ There's a small thing. Whether the input is 12 / 30 or 12/30 or even 12 / 30 it should get the input as 12th month and the 30th day.

// Assume that every month is 30 days within this program.

I've made a code but it only works if I type in g++ -std=c++11 Main.cpp Date.cpp -o programName, I believe it should work without any extra parameters. Anyway, the OS that I have to use is Ubuntu 12.04 LTS, if it matters... I'll also provide some example inputs and output files.

Task: Implementing a simple Date class, given its interface (Date.h)

You are given two files: Date.h and Main.cpp. You CAN NOT change these files, but will only use them during development. Note that you will only submit Date.cpp file.

Write Date.cpp that implements the public interface functions defined in Date.h.

Date data will be provided as strings and you are responsible from the internal representation of Date type so that it provides necessary working functions properly.

Date string format:

{Space} / {Space}

{.} representation encodes 0 or more.

Ex: 10/28 : 28th of October

10/08, 10/8 will be treated equivalently, or 02/07 and 2/7 etc.

We recommend you to use Months array, so that there will be no inconsistencies in the month names with the given output files.

You need to write the constructor and add_dayfunctions.

Even if you can not implement add_daymember function properly, when you submit a compiling source code, you may still get 50% by your constructor implementation.Only half of the output files check for add_day functionality.

Please check the sample input/output files before starting your implementation.

Testing:

We provide a sample input/output text file pairs for you to test your codes at Ubuntu. We recommend you to use input redirection mechanism of your operating system to test your programs. For example, if your executable is called as Lab3, redirect the input.txt file to standard input using < operator and redirect your outputs to a file using > operator such as:

> ./Lab3output.txt

This kind of execution enables your programs to read inputs from a file without writing any file related functions. In other words, cin reads data from the redirected files instead of the std. input in this way (e.g. keyboard).

Since Chegg screws up the code format I'll share it over CodeShare:

Main.cpp File (SHOULDN'T BE MODIFIED):

https://codeshare.io/50bx4g

Date.h File (SHOULDN'T BE MODIFIED):

https://codeshare.io/21V1yq

Date.cpp File -- you need to write this one :(

Good luck! Thanks for helping. Also here are some pre-rendered input-output files:

Example Input2:

08 / 15 0 12 / 30 0 01 / 04 0 end

Output2:

Date: 15'th of August How many days to add? OK. Not changing the date Date: 30'th of December How many days to add? OK. Not changing the date Date: 4'th of January How many days to add? OK. Not changing the date

Example Input3:

7 / 15 20 12 / 30 75 03 / 4 40 end

Output3:

Date: 15'th of July How many days to add? adding 20 days to Date: 15'th of July Date: 5'th of August Date: 30'th of December How many days to add? adding 75 days to Date: 30'th of December Date: 15'th of March Date: 4'th of March How many days to add? adding 40 days to Date: 4'th of March Date: 14'th of April

Input4:

12/30 30 12/30 90 12/30 420 end

Output4:

Date: 30'th of December How many days to add? adding 30 days to Date: 30'th of December Date: 30'th of January Date: 30'th of December How many days to add? adding 90 days to Date: 30'th of December Date: 30'th of March Date: 30'th of December How many days to add? adding 420 days to Date: 30'th of December Date: 30'th of February

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!