Question: Write a class named Cursor that models an integer cursor . When created, the cursor object should have value 0 . The class should support

Write a class named Cursor that models an integer cursor. When created, the cursor object should have value 0. The class should support method curr() that returns the value of the cursor, method next() that increments the value of the cursor, and method prev() that decrements the value of the cursor. Metholds prev() and next() should also return the new value of the cursor. A ValueError exception should be raised if method prev() is called when the cursor value is 0. >>> cursor = Cursor()>>> cursor.curr()0>>> cursor.next()1>>> cursor.curr()1>>> cursor.prev()0>>> cursor.curr()0>>> cursor.prev() Traceback (most recent call last): File "", line 1, in cursor.prev() File "/Users/me/ch8.py", line 54, in prev raise ValueError('Illegal cursor operation') ValueError: Illegal cursor operation

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!