before
Category: Programming
Author: Stuart Reges
Book Chapter: 5.3
Problem: before
Write a method before that takes as parameters two
month/day combinations and that returns whether or not the first date comes
before the second date (true if the first month/day comes before the second
month/day, false if it does not). The method will take four integers as
parameters that represent the two month/day combinations.
The first integer in each pair represents the month and will be a value
between 1 and 12 (1 for January, 2 for February, etc, up to 12 for
December). The second integer in each pair represents the day of the month
(a value between 1 and 31). One date is considered to come before another
if it comes earlier in the year.
For example, the call:
before(6, 3, 9, 20)
should return true because June 3rd (6/3) comes before September 20th
(9/20). By contrast, the call:
before(10, 1, 2, 25)
should return false because October 1st (10/1) comes after February 25th
(2/25). If the same date is passed twice, your method should return false.
For example:
before(8, 15, 8, 15)
should return false because August 15th (8/15) does not come before August
15th (8/15).
You may assume that your method is passed values that represent legal dates.
Write your solution to before below.