Forums Register Login

Increment Day Object Help

+Pie Number of slices to send: Send

Hi there. I'm new to this forum and Java. I'm currently taking a class in Java and was hoping someone could help me out. I'm stuck and I don't know what to do. Here is the question-

Write a program that generates a Day object
representing February 28 of this year, and three more such objects that represent
February 28 of the next three years. Advance each object by one day, and print each
object. Also print the expected values.
Expected Results
----------------
2015-02-28 + one day == 2015-03-01
Expected: 2015-3-1
2016-02-28 + one day == 2016-02-29
Expected: 2016-2-29
2017-02-28 + one day == 2017-03-01
Expected: 2017-3-1
2018-02-28 + one day == 2018-03-01
Expected: 2018-3-1

Any help would be greatly appreciated!
+Pie Number of slices to send: Send
 

Simone Taylor wrote:
Write a program that generates a Day object
representing February 28 of this year


You need a Day object, and think what fields it should contains.

Simone Taylor wrote:Advance each object by one day


Day should have a method for you to advance by one day

Simone Taylor wrote:, and print each
object. Also print the expected values.


Day should have a method to print its current content
+Pie Number of slices to send: Send
Hi Simone, Welcome to the Ranch!

Raymond has given some good hints. Please post what you have tried so far so we can give more guidance. When posting code, please UseCodeTags (← click on that link to learn how).
For my next trick, I'll need the help of a tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 699 times.
Similar Threads
help with validation/ 2 functions on submit.
Printing all days of the week
Complex Parsing XML Using SAX
Transform text file to xml file
Transform text file to xml
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 09:30:18.