class Lines – the code

class Lines{
  Line[] lines;
  
  Lines(){
    lines=new Line[0];
  }
  
  void add(Line l){
    lines=(Line[])(append(lines,l));
  }
  
  void eliminateUndefined(){   
    lines=eliminateUndefinedLines(lines);
  }

  void eliminateUndefinedDuals(){   
    for (int i=0;i<lines.length;i++){
      lines[i].eliminateUndefinedDual();
    }
  }

  void show(){
    for (int i=0;i<lines.length;i++){
      lines[i].show();
    }
  }  
}

 //eliminate lines with undefined endpoints,also used for connections
 
Line[] eliminateUndefinedLines(Line[] lines){
   int lookAt;
   lookAt=0;
   while (lookAt < lines.length){
     if(lines[lookAt].undefined()){
       lines[lookAt]=lines[lines.length-1];
       lines=(Line[])(shorten(lines));
    }
     else {
       lookAt++;
     }    
   }
   return lines;
}
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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s