Skip to content
Advertisement

How to create a functioning program that acts like a calendar with methods that block multiple ranges of dates and return the available dates?

The following is what I was able to complete:

JavaScript

For the setBlockDates() method: write a method to block multiple ranges of dates from the dateRange ArrayList. Here I should be able to enter multiple ranges to block, such as ([1,4], [8,11], [17,24])

For the getAvailableDates() method: write a method to return the available dates in the dateRange ArrayList created below. the return should be an ArrayList like the following if the date ranges ([1,4], [8,11], [17,24]) were blocked on the calendar:

[5, 6, 7, 12, 13, 14, 15, 16, 25, 26, 27, 28, 29, 30, 31]

Any help would be appreciated!

Advertisement

Answer

I’ll assume the input parameter for the setBlockDates() to be a two-dimensional int array.

JavaScript

The setBlockDates() takes a two-dimensional array as input, and adds a range of each array to blockedDates. The getAvailableDates() returns an ArrayList<Integer> that doesn’t include all the ints in blockedDates.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement