Question
With the language Smalltalk, create a new class category through the System Browser called CPS506, and a new class called Lab1. Your Lab1 class will
With the language Smalltalk, create a new class category through the System Browser called CPS506, and a new class called Lab1. Your Lab1 class will implement a rudimentary circular buffer. It must have the following methods and instance variables:
-
- A method called bufferInit: that accepts an array of literals as an argument.
-
- An instance variable called arr that is used to store the array object passed with the bufferInit: message.
-
- A method called getElem: that accepts an integer as an argument. This integer is to be used as a circular index. Out-of-bounds indexes should correctly wrap around. This includes negative values! Remember that Smalltalk is 1-indexed. An argument of 1 should correctly return the first element, and an argument of 0 should return the last element.
All of this can be done with some clever arithmetic. You dont need any branching or control structures.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started