Triangle Class

As well as a circle and a square, we could define a triangle.

Triangle Class

As well as a circle and a square, we could define a triangle.

Triangle Class

As well as a circle and a square, we could define a triangle.

Triangle Class

As well as a circle and a square, we could define a triangle.

Triangle Class

As well as a circle and a square, we could define a triangle.

Triangle Class

Finished code.

class Circle {
private int x=50, y=50;
private int size=20;

public void moveTo(int xpos, int ypos){
	x=xpos; y=ypos;
	}

public void draw(java.awt.Graphics g){
	g.drawOval(x, y, size, size);
	}

}

class Circle {
private int x=50, y=50;
private int size=20;

public void moveTo(int xpos, int ypos){
	x=xpos; y=ypos;
	}

public void draw(java.awt.Graphics g){
	g.drawOval(x, y, size, size);
	}

}

class Triangle {
private int x=50, y=50;
private int size=20;

public void moveTo(int xpos, int ypos){
	x=xpos; y=ypos;
	}

public void draw(java.awt.Graphics g){
	g.drawOval(x, y, size, size);
	}

}

class Triangle {
private int x=50, y=50;
private int size=20;

public void moveTo(int xpos, int ypos){
	x=xpos; y=ypos;
	}

public void draw(java.awt.Graphics g){
	g.drawOval(x, y, size, size);
	}

}

class Triangle {
private int x=50, y=50;
private int size=20;

public void moveTo(int xpos, int ypos){
	x=xpos; y=ypos;
	}

public void draw(java.awt.Graphics g){
	g.drawLine(x, y, x+size, y);
	g.drawLine(x+size, y, x+size/2, y+size);
	g.drawLine(x+size/2, y+size, x, y);
	}

}

class Triangle {
private int x=50, y=50;
private int size=20;

public void moveTo(int xpos, int ypos){
	x=xpos; y=ypos;
	}

public void draw(java.awt.Graphics g){
	g.drawLine(x, y, x+size, y);
	g.drawLine(x+size, y, x+size/2, y+size);
	g.drawLine(x+size/2, y+size, x, y);
	}

}