import java.awt.*; public class drawTriangle { private int [] xPoints; private i
ID: 3645993 • Letter: I
Question
import java.awt.*;public class drawTriangle {
private int [] xPoints;
private int [] yPoints;
public drawTriangle(int [] points1, int [] points2){
xPoints = points1;
yPoints = points2;
}
public int[] getxPoints() {
return xPoints;
}
public void setxPoint(int[] xPoints) {
this.xPoints = xPoints;
}
public int[] getyPoints() {
return yPoints;
}
public void setyPoint(int[] yPoints) {
this.yPoints = yPoints;
}
public void display (Graphics g) {
g.drawPolygon(xPoints, yPoints, 3);
}
}
import java.awt.*;
public class drawHouse extends drawTriangle {
private int upperLeftX;
private int upperLeftY;
private int height;
private int width;
public drawHouse(int upperX, int upperY, int h, int w,int [] points1, int [] points2){
super (points1, points2);
upperLeftX = upperX;
upperLeftY = upperY;
height = h;
width = w;
drawTriangle Triangle = new drawTriangle(points1, points2);
}
public int getUpperLeftX() {
return upperLeftX;
}
public void setUpperLeftX(int upperLeftX) {
this.upperLeftX = upperLeftX;
}
public int getUpperLeftY() {
return upperLeftY;
}
public void setUpperLeftY(int upperLeftY) {
this.upperLeftY = upperLeftY;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public void display(Graphics g) {
g.fillRect(upperLeftX,upperLeftY,width,height);
}
}
import java.awt.*;
import java.applet.Applet;
public class Construction extends Applet {
drawHouse House1 = new drawHouse(?);
}
How do I use the display in drawTriangle in the display function in drawHouse? Also what do I put between the parentheses in new drawHouse(.......)?
Explanation / Answer
import java.io.*; class triangle{ public static void main(String[] args) { try{ BufferedReader object = new BufferedReader (new InputStreamReader(System.in)); System.out.println("enter the number"); int a= Integer.parseInt(object.readLine()); for (int i=1; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.