i am trying to drewan line using "*"
<p>i am trying to drewan line using "<code>*</code>" in the console . but i get only 2 "<code>*</code>". i think something is wrong with the line algorithm . maybe there is an easier way to do it.</p>

<pre><code> class MyGraphics {
int x, y;
private int width, height;
MyGraphics(int wid, int hit) {

    fb= new FrameBuffer(wid,hit);
    width = fb.getWidth();
    height = fb.getHeight();
}
MyGraphics() {
    fb = new FrameBuffer();
    width = fb.getWidth();
    height = fb.getHeight();
}

void drawLine(int x1,int y1,int x2,int y2)
{
 width= x2 - x ;
height = y2 - y ;
   int dx1 = 0, dy1 = 0, dx2 = 0, dy2 = 0 ;
    if (width&lt;0) dx1 = -1 ; else if (width&gt;0) dx1 = 1 ;
   if (height&lt;0) dy1 = -1 ; else if (height&gt;0) dy1 = 1 ;
   if (width&lt;0) dx2 = -1 ; else if (width&gt;0) dx2 = 1 ;
   int longest = Math.abs(width) ;
   int shortest = Math.abs(height) ;
  if (!(longest&gt;shortest)) {
    longest = Math.abs(height) ;
    shortest = Math.abs(width) ;
    if (height&lt;0) dy2 = -1 ; else if (height&gt;0) dy2 = 1 ;
    dx2 = 0 ;
}
int numerator = longest &gt;&gt; 1 ;
for (int i=0;i&lt;=longest;i++) {
    fb.setPixel(x1, y1);

    numerator += shortest ;
    if (!(numerator&lt;longest)) {
        numerator -= longest ;
        x += dx1 ;
        y += dy1 ;
    } else {
        x += dx2 ;
        y += dy2 ;
    }
}
return;
}
void display() {
    fb.display();
    return;
    } // simply calls the frame buffer's display method

FrameBuffer fb;
}



/*void drawLine(int x1,int y1,int x2,int y2)
{
width= x2 - x ;
height = y2 - y ;
int dx1 = 0, dy1 = 0, dx2 = 0, dy2 = 0 ;
if (width&lt;0) dx1 = -1 ; else if (width&gt;0) dx1 = 1 ;
if (height&lt;0) dy1 = -1 ; else if (height&gt;0) dy1 = 1 ;
if (width&lt;0) dx2 = -1 ; else if (width&gt;0) dx2 = 1 ;
int longest = Math.abs(width) ;
int shortest = Math.abs(height) ;
if (!(longest&gt;shortest)) {
    longest = Math.abs(height) ;
    shortest = Math.abs(width) ;
    if (height&lt;0) dy2 = -1 ; else if (height&gt;0) dy2 = 1 ;
    dx2 = 0 ;
}
int numerator = longest &gt;&gt; 1 ;
for (int i=0;i&lt;=longest;i++) {
    fb.setPixel(y, x);

    numerator += shortest ;
    if (!(numerator&lt;longest)) {
        numerator -= longest ;
        x += dx1 ;
        y += dy1 ;
    } else {
        x += dx2 ;
        y += dy2 ;
    }
}
return;
}*/
</code></pre>

<p>//////////////////////////////////////////////////////////////////////////////////////</p>

<pre><code>class MyGraphicsApp {
MyGraphicsApp() {mg = new MyGraphics(80, 25);}

void paint(MyGraphics g) {
    g.drawLine(5, 12, 27, 2);
    g.drawLine(2, 2, 30, 30);
}

void repaint() {
    paint(mg);
    mg.display();
}

public static void main(String [] args) {
    MyGraphicsApp myGraphicsApp = new MyGraphicsApp();
    myGraphicsApp.repaint();
}

MyGraphics mg;
}
</code></pre>
