Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Object Oriented Programming in Skill++

35 views
Skip to first unread message

Suresh Jeevanandam

unread,
Feb 16, 2017, 6:38:27 AM2/16/17
to
I am exploring OOPs in Skill++.

I want to create a simple Rectangle class with a @reader function to return area and a method which moves the shape by given dx and dy.

Defining the class is easy.

defclass(Rectangle ()
((x1 @initarg x1)
(x2 @initarg x2)
(y1 @initarg y1)
(y2 @initarg y2)
)

I could not find out how to define the reader and method from the User's guide.

I tried adding the reader function as below, but it does not work.

let(()
defmethod( getArea (( self Rectangle ))
(self->x2 - self->x1) * (self->y2 - self->y1)
)
defclass(Rectangle ()
((x1 @initarg x1)
(x2 @initarg x2)
(y1 @initarg y1)
(y2 @initarg y2)
(area @reader getArea))
)

)

I also want to add the method move(dx, dy) which moves the shape (updates all coordinates). What is the best way to do this?

Thanks.,
Suresh

--
I tried posting this first in community.cadence.com but I don't see any button to start a new topic even after logging-in successfully.
0 new messages