@@ -25,7 +25,7 @@ def __str__(self):
2525
2626
2727class Report :
28- def __init__ (self , limit : int ):
28+ def __init__ (self , limit ):
2929 self .limit = limit
3030 self .rows = []
3131
@@ -44,7 +44,8 @@ def size(self):
4444 def get_number_of_pages (self ):
4545 """
4646 Get how many pages the report has; this will be based on limit variable.
47- If your limit=4 and rows list has 6 records then there are two pages: page1 has 4 records, page2 has 2 records
47+ If your limit=4 and rows list has 6 records then there are two pages:
48+ page1 has 4 records, page2 has 2 records
4849 hint: you'll want to round up
4950 """
5051 pass
@@ -75,43 +76,43 @@ def get_paged_rows(self, sort_field, page):
7576 pass
7677
7778
78- if __name__ == "__main__" :
79-
80- report = Report (4 )
79+ def run_report (sort_field ):
80+ print (f"... PAGED REPORT SORTED BY: '{ sort_field } '..." )
81+ page = 1
82+ while True :
83+ rows = report .get_paged_rows (sort_field , page = page )
8184
82- report .add_row (Row ("natasha" , "smith" , "WA" ))
83- report .add_row (Row ("devin" , "lei" , "WA" ))
84- report .add_row (Row ("bob" , "li" , "CA" ))
85- report .add_row (Row ("tracy" , "jones" , "OR" ))
86- report .add_row (Row ("johny" , "jakes" , "WA" ))
87- report .add_row (Row ("derek" , "wright" , "WA" ))
85+ if not rows :
86+ break
8887
88+ input (f"Press ENTER to see page { page } " )
8989
90- def run_report (sort_field ):
91- print (f"... PAGED REPORT SORTED BY: '{ sort_field } '..." )
92- page = 1
93- while True :
94- rows = report .get_paged_rows (sort_field , page = page )
90+ print (f"PAGE: { page } of { report .get_number_of_pages ()} " )
91+ print ("---------------------------------------------------------------" )
9592
96- if not rows :
97- break
93+ for row in rows :
94+ print ( row )
9895
99- input ( f"Press ENTER to see page { page } " )
96+ print ( "--------------------------------------------------------------- " )
10097
101- print (f"PAGE: { page } of { report .get_number_of_pages ()} " )
102- print ("---------------------------------------------------------------" )
98+ page += 1
10399
104- for row in rows :
105- print (row )
106100
107- print ( "---------------------------------------------------------------" )
101+ if __name__ == "__main__" :
108102
109- page += 1
103+ report = Report ( 4 )
110104
105+ report .add_row (Row ("natasha" , "smith" , "WA" ))
106+ report .add_row (Row ("devin" , "lei" , "WA" ))
107+ report .add_row (Row ("bob" , "li" , "CA" ))
108+ report .add_row (Row ("tracy" , "jones" , "OR" ))
109+ report .add_row (Row ("johny" , "jakes" , "WA" ))
110+ report .add_row (Row ("derek" , "wright" , "WA" ))
111111
112112 run_report ("fname" )
113113
114- print (f"\n \n Removing student: { report .rows [1 ].fname } [{ report .rows [1 ].row_id } ]... \n \n " )
114+ print ("\n \n Removing student: "
115+ f"{ report .rows [1 ].fname } [{ report .rows [1 ].row_id } ]... \n \n " )
115116
116117 report .remove_row (report .rows [1 ].row_id )
117118
0 commit comments