class Line – the code

class Line{
  Point endPointA,endPointB;
  Line dualLine;
  Line(Point ap,Point bp){              // with known endpoints 
    if(ap==bp) {
      println( " *********** new Line: IDENTICAL endpoints,  a==b, NO LINE"); 
  Line(){                     // only the existence is known
  void setDual(Line d){           // define the dual line
  void eliminateUndefinedDual(){       // eliminate undefined dual
    if(dualLine==null) return;
    if(dualLine.undefined()) dualLine=null;
  void setAnEndPoint(Point p){       //  set one endpoint (dual lines, orientation not important)
    if(endPointA==null) {
    if(endPointB==null) {
    println(" setAnEndPoint: both are already occupied");
  boolean undefined(){
        if((endPointA==null)||(endPointB==null)) return true;
    return ((endPointA.vec==null)||(endPointB.vec==null));

  void show(){
  //  if (undefined()) return;
  //  return other endpoint than given endpoint, note: may be null
  Point getOtherEndPoint(Point p){
    if(endPointA==p) return endPointB;
    if(endPointB==p) return endPointA;
    println(" Problem in otherEndPointA:  point p not found");
    Point nothing=null;
    return nothing;    
  //  search for common endpoint
  Point commonEndPoint(Line two){
    if((endPointA==two.endPointA)||(endPointA==two.endPointB)) return endPointA;
    if((endPointB==two.endPointA)||(endPointB==two.endPointB)) return endPointB;
    println(" no common endpoint");
    Point nothing=null;
    return nothing;
This entry was posted in programming and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s