public class  Line
{
  private char theLine[];
  private int width;
  private char fill;

  public Line(int width, char fill)
  {
    if(width < 1)
    {
      System.out.println("Lines must not have negative width.");
      System.exit(1);
    }
    this.theLine = new char[width];
    this.fill = fill; 
    this.width = width;
    for(int i = 0; i < this.width; i++)
    {
      this.theLine[i] = this.fill;
    }
  }

  public int getWidth()
  {
    return this.width;
  }

  public char getFill()
  {
    return this.fill;
  }

  public char getPixel(int where)
  {
    char retval = this.fill;
    if(where >= 0 && where < this.width)
    {
      retval = this.theLine[where];
    }
    return retval;
  }

  public void setPixel(int where, char what)
  {
    if(where >= 0 && where < this.width)
    {
      this.theLine[where] = what;
    }
  }

  public String toString()
  {
    String retval = "";
    for(int i = 0; i < this.width; i++)
    {
      retval += this.theLine[i];
    }
    return retval;
  }

  public Line(int width)
  {
    this(width, ' ');
  }  


  public static void main(String args[])
  {
    Line myLine =  new Line(50, '*');
    System.out.println(myLine);
    myLine.setPixel(25, '!');
    System.out.println(myLine);
    char x = myLine.getPixel(25);
    System.out.println("Found " + x);
  }
}
