Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write complete Jaava program that creats a subclass Pinetree of the Tree class.

ID: 3674396 • Letter: W

Question

Write complete Jaava program that creats a subclass Pinetree of the Tree class. It contains:

1:Prime Properties ConeNum(double) and LeafShape(string)

2: Both default and standard constructors

3: Public methods (void type)growCone and display ()

In addition, get and set methods for each of its own properties.in the testPineTree class, create two objects P1, P2 from each of constructors. Then call ALL accessible methods from and P2, including methods of its superclass.

I know it doesnt make much sense, my teacher has horrible handwritting and i did the best i can.

Explanation / Answer

import java.awt.*;import java.applet.*;

public class Java1019 extends Applet{public void paint(Graphics g)

{

PineTree tree3 = new PineTree();tree3.drawTree(g);

}

}

class PineTree extends Tree{public PineTree()

{

setLeavesColor(Color.green);

}

public void drawLeaves(Graphics g)

{

g.setColor(getLeavesColor());

int tempX = getLeavesStart().getX();

int tempY = getLeavesStart().getY();

int topX = tempX + getLeavesWidth()/2;

int topY = tempY;int blX = tempX;

int blY = tempY + getLeavesHeight();

int brX = tempX + getLeavesWidth();

int brY = tempY + getLeavesHeight();

Polygon triangle = new Polygon();

triangle.addPoint(topX,topY);

triangle.addPoint(blX,blY);

triangle.addPoint(brX,brY);

g.fillPolygon(triangle);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote