Ticket #865 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

Error in TOLDoc/OOP code example

Reported by: cperez Owned by: vdebuen
Priority: low Milestone: OOP Implementation
Component: Web Version:
Severity: minor Keywords:
Cc:

Description (last modified by vdebuen) (diff)

In the section of the documentation TOLDOC/OOP, there is an example that has some errors. Is the code in the section "Constructores de instancias". The following code is right (I hope:) :

Class @Circle
{
//Definition members
  Real _.center.x_;
  Real _.center.y_;
  Real _.radius;

//Auxiliar members
  Real _.perimeter;
  Real _.area;
  
//Basic Constructor 
  Static @Circle New(
    Real x,  //First coordinate of center 
    Real y,  //Second coordinate of center 
    Real r)  //Radius
  {
    @Circle new =
    [[
      Real _.center.x_ = x;
      Real _.center.y_ = y;
      Real _.radius = r;
      //Auxiliuar members definition
      Real _.perimeter = 2*Pi*r;
      Real _.area = Pi*r^2
    ]]
  };
//Derivate constructor
  Static @Circle Random(
   Real min.x, Real max.x,
   Real min.y, Real max.y,
   Real min.r, Real max.r)
  {
    @Circle::New(Rand(min.x,max.x),
                 Rand(min.y,max.y),
                 Rand(min.r,max.r))
  };

//Returns true if the point (x,y) is inside the circle
Real includes(Real x, Real y)
{
  (x-_.center.x_)^2+(y-_.center.y_)^2<=_.radius^2
};
Real outsides(Real x, Real y){ Not(includes(x,y)) }
};

Change History

Changed 4 years ago by vdebuen

  • owner changed from apalonso to vdebuen
  • status changed from new to assigned

Thanks for reporting

Changed 4 years ago by vdebuen

  • status changed from assigned to accepted

Changed 4 years ago by vdebuen

  • status changed from accepted to closed
  • resolution set to fixed
  • description modified (diff)
  • milestone set to OOP Implementation

Indeed the code had become obsolete.
I've put your version in the wiki

Note: See TracTickets for help on using tickets.