task3 #2
@ -28,9 +28,11 @@ class PaginationHelper:
|
|||||||
if page_index == 0:
|
if page_index == 0:
|
||||||
return len(self.collection[: self.items_per_page])
|
return len(self.collection[: self.items_per_page])
|
||||||
|
|
||||||
return self.collection[
|
return len(
|
||||||
self.items_per_page * page_index : self.items_per_page * page_index * 2
|
self.collection[
|
||||||
]
|
self.items_per_page * page_index : self.items_per_page * page_index * 2
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
# determines what page an item at the given index is on. Zero based indexes.
|
# determines what page an item at the given index is on. Zero based indexes.
|
||||||
# this method should return -1 for item_index values that are out of range
|
# this method should return -1 for item_index values that are out of range
|
||||||
@ -38,8 +40,8 @@ class PaginationHelper:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
collection = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
|
collection = ["a", "b", "c", "d", "e", "f"]
|
||||||
helper = PaginationHelper(collection, 4)
|
helper = PaginationHelper(collection, 4)
|
||||||
|
|
||||||
print(helper.page_count())
|
print(helper.page_count())
|
||||||
print(helper.page_item_count(2))
|
print(helper.page_item_count(1))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user