Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class, MyDate, which contains (at least) the following: - A constructor that receives 3 integer values for day, month and year. The constructor

image text in transcribed

Create a class, MyDate, which contains (at least) the following: - A constructor that receives 3 integer values for day, month and year. The constructor should provide default values for day, month and year as 1 January 1970. - A method called subtract which receives another MyDate object as a parameter. This method must subtract the received MyDate object from the MyDate object on which the method is called. Subtraction should happen as follows: - The calculated year should be the average value of the current object's year and that of the received MyDate object's year, e.g. if the 2 years are 2020 and 2010, the new year value should be 2015. - The month of the received MyDate should be subtracted from the current object. If the calculated month is less than 0 , it should default to a value of 1. - The day of the received MyDate should be subtracted from the current object. If the calculated day is less than 0 , it should default to a value of 1. - An override of the str method that outputs a MyDate in the format day month name year, e.g. 1 January 1970

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_2

Step: 3

blur-text-image_3

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

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions