For this exercise you will be strengthening your page-fu mastery. You will complete the PaginationHelper class, which is a utility class helpful for querying paging information related to an array.
The class is designed to take in an array of values and an integer indicating how many items will be allowed per each page. The types of values contained within the collection/array are not relevant.
The following are some examples of how this class is used:
var helper = new PaginationHelper(['a','b','c','d','e','f'], 4);
helper.pageCount();
helper.itemCount();
helper.pageItemCount(0);
helper.pageItemCount(1);
helper.pageItemCount(2);
helper.pageIndex(5);
helper.pageIndex(2);
helper.pageIndex(20);
helper.pageIndex(-10);
helper = PaginationHelper(Char).new(['a','b','c','d','e','f'], 4);
helper.page_count()
helper.item_count()
helper.page_item_count(0)
helper.page_item_count(1)
helper.page_item_count(2)
helper.page_index(5)
helper.page_index(2)
helper.page_index(20)
helper.page_index(-10)
PaginationHelper<Character> helper = new PaginationHelper(Arrays.asList('a', 'b', 'c', 'd', 'e', 'f'), 4);
helper.pageCount();
helper.itemCount();
helper.pageItemCount(0);
helper.pageItemCount(1);
helper.pageItemCount(2);
helper.pageIndex(5);
helper.pageIndex(2);
helper.pageIndex(20);
helper.pageIndex(-10);
helper = new PaginationHelper(['a','b','c','d','e','f'], 4)
helper.pageCount()
helper.itemCount()
helper.pageItemCount(0)
helper.pageItemCount(1)
helper.pageItemCount(2)
helper.pageIndex(5)
helper.pageIndex(2)
helper.pageIndex(20)
helper.pageIndex(-10)
helper = PaginationHelper.new(['a','b','c','d','e','f'], 4)
helper.page_count()
helper.item_count()
helper.page_item_count(0)
helper.page_item_count(1)
helper.page_item_count(2)
helper.page_index(5)
helper.page_index(2)
helper.page_index(20)
helper.page_index(-10)
collection = ['a','b','c','d','e','f']
itemsPerPage = 4
pageCount collection itemsPerPage `shouldBe` 2
itemCount collection itemsPerPage `shouldBe` 6
pageItemCount collection itemsPerPage 0 `shouldBe` Just 4
pageItemCount collection itemsPerPage 1 `shouldBe` Just 2
pageItemCount collection itemsPerPage 3 `shouldBe` Nothing
pageIndex collection itemsPerPage 0 `shouldBe` Just 0
pageIndex collection itemsPerPage 5 `shouldBe` Just 1
pageIndex collection itemsPerPage 20 `shouldBe` Nothing
pageIndex collection itemsPerPage (-20) `shouldBe` Nothing
helper = PaginationHelper(['a','b','c','d','e','f'], 4)
helper.page_count()
helper.item_count()
helper.page_item_count(0)
helper.page_item_count(1)
helper.page_item_count(2)
helper.page_index(5)
helper.page_index(2)
helper.page_index(20)
helper.page_index(-10)
var helper = new PaginationHelper<char>(new List<char>{'a', 'b', 'c', 'd', 'e', 'f'}, 4);
helper.PageCount;
helper.ItemCount;
helper.PageItemCount(0);
helper.PageItemCount(1);
helper.PageItemCount(2);
helper.PageIndex(5);
helper.PageIndex(2);
helper.PageIndex(20);
helper.PageIndex(-10);
val helper = PaginationHelper<Char>(listOf('a', 'b', 'c', 'd', 'e', 'f'), 4)
helper.pageCount
helper.itemCount
helper.pageItemCount(0)
helper.pageItemCount(1)
helper.pageItemCount(2)
helper.pageIndex(5)
helper.pageIndex(2)
helper.pageIndex(20)
helper.pageIndex(-10)
let helper = new PaginationHelper(["a", "b", "c", "d", "e", "f"], 4)
helper.pageCount()
helper.itemCount()
helper.pageItemCount(0)
helper.pageItemCount(1)
helper.pageItemCount(2)
helper.pageIndex(5)
helper.pageIndex(2)
helper.pageIndex(20)
helper.pageIndex(-10)
let helper = PaginationHelper::new(vec!['a', 'b', 'c', 'd', 'e', 'f'], 4);
helper.page_count()
helper.item_count()
helper.page_item_count(0)
helper.page_item_count(1)
helper.page_item_count(2)
helper.page_index(5)
helper.page_index(2)
helper.page_index(20)