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 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 cursor Cursor cursor.curr cursor.next cursor.curr cursor.prev cursor.curr cursor.prev Traceback most recent call last: File line in cursor.prev File Usersmechpy line in prev raise ValueErrorIllegal cursor operation' ValueError: Illegal cursor operation
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
