1
$\begingroup$

I have been doing a lot of object-oriented programming lately, so my question is a little related to it.

I was teaching mathematics (geometry) to my friend and I came up with a question:

In Scala we would have circle probably defined as this:

class Circle(val radius: Double) {

def area = π*radius^2

def diameter = 2*radius

...

}

So Circle class has a property name "radius" and methods (area, diameter, etc.) which use "radius" in calculations.

Are these all "properties" of a circle in mathematics, or are there different terms for radius (since everything is defined by radius) and methods such as an area?

$\endgroup$
1
  • $\begingroup$ A circle is defined fully its radius... if you fix a coordinate system you need a centre and a radius. $\endgroup$ Nov 23, 2015 at 11:18

1 Answer 1

1
$\begingroup$

From a programmer's point of view, these are properties if you can invoke them without a (void) argument list.

Like print MyCircle.Area, rather than MyCircle.Area(), which would be a method.

If the properties are wrapped, one could also consider that GetArea() is a property, in the same sense as GetRadius().

In your description, Area seems to be a read-only property (hence no setter). But it could be otherwise, by defining

def SetArea(val Area: Double) radius= sqrt(Area / π)
$\endgroup$
1
  • $\begingroup$ I don't known the Scala syntax. $\endgroup$
    – user65203
    Nov 23, 2015 at 11:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .