blahbla 1 Newbie Poster

need some help with this lab
this class is to draw a line with *'s
i guess in the command prompt since it uses System.out to print

i was given the function names and the comments that tells me what the function does
i wrote the code in the functions of the FrameBuffer class
those comments and the main are the only info i have on how to write it

public class FrameBuffer {
    FrameBuffer(int width, int height) {	////// Creates a frame buffer of specified resolution 
		this.width = width;
		this.height = height;
		pixels = new boolean [width][height];
		clear();
		}
    FrameBuffer() {		////// Creates a default-sized frame buffer
		width = 50;
		height = 20;
		pixels = new boolean [width][height];
		clear();
	}	

    void setPixel(int x, int y, boolean b) {pixels[x][y] = b;} //// Sets pixel (x, y) to b
    void setPixel(int x, int y) {pixels[x][y] = true;}		//// Sets pixel (x, y) to true 

    int getWidth() {return width;}
    int getHeight() {return height;}

    void clear() {		///// Clears frame buffer
		for(int i=0;i<width;i++)
			for(int j=0;j<height;j++)
				setPixel(i,j,false);
	}	 

    void display() {	///// displays frame buffer on System.out as " "'s and "*"s
		for(int i=0;i<width;i++)
			for(int j=0;j<height;j++)
				if(pixels[i][j] == true)
					System.out.print("*");
				else System.out.print(" ");
	}
		
    private boolean pixels[][];      //////this was given 
    private int width, height;      //////this was given


public static void main(String [] args) {     ///////the main was given as well
        FrameBuffer fb = new FrameBuffer();
        int x = 0, y = 0;
        while (x < fb.getWidth()) {
            while (x < fb.getWidth() && y < fb.getHeight())
                fb.setPixel(x++, y++);
            y--;

            while (x < fb.getWidth() && y >= 0)
                fb.setPixel(x++, y--);
            if (y < 0)y = 0;
        }

        fb.display();
    }

}

i wrote the stuff in the class FrameBuffer
the main was tested and it works
its output is some thing like a v or w depending on how big it is
:::

*              **
 *            *  *
  *          *    *
   *        *      *
    *      *        *
     *    *          *
      *  *            *
       **              **

but when i run my code it comes out something like this ::

*      *      *
 *      *      *
  *      *      *
   *      *      *
    *      *      *
     *      *      *
    *      *      *
   *      *      *
  *      *      *
 *      *      *
*      *      *
 *      *      *
  *      *      *

i cant figure out why it does this, dont understand why it does this as well
i'd like any help at all but if it is possible dont give me the code, i still want to do it myself
what i did wrong? something i'm missing? i'd like some hints, pushing in the right direction, stuff like that

any help is much appreciated
thanks in advance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.