Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 image text in transcribedto 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.

1) Next, create a new class category through the System Browser called CPS506, and a new class called Lab1. Check the lecture slides for a reference on how to do this. 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 O should return the last element. All of this can be done with some clever arithmetic. You don't need any branching or control structures

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions