Definition of a Smalltalk class

Definition of a Smalltalk class.

Type: Code

Summary:

by Deyi Xue

Developing a Superset Language of Smalltalk for Modeling Mechanical Systems
Deyi Xue

Listing 1. Definition of a Smalltalk class.


Object subclass: #Cylinder
  instanceVariableNames: 'radius height '
  classVariableNames: 'Pi '
  poolDictionaries: ''
  category: 'Geometry-Objects'

Class methods:
  initialize
    ^self new assignPi

Instance methods:
  assignHeight: h
            height := h

  assignPi
            Pi := 3.14159

  assignRadius: r
            radius := r

  getVolume
    ^Pi * radius * radius * height