Westonci.ca is the ultimate Q&A platform, offering detailed and reliable answers from a knowledgeable community. Get immediate and reliable solutions to your questions from a community of experienced experts on our Q&A platform. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields.

Look at the following Polygon class:
public class Polygon
{
private int numSides;

public Polygon()
{
numSides = 0;
}

public void setNumSides(int sides)
{
numSides = sides;
}

public int getNumSides()
{
return numSides;
}
}
Write a public class named Triangle that is a subclass of the Polygon class. The Triangle class should have the following members:
a private int field named base
a private int field named height
a constructor that assigns 3 to the numSides field and assigns 0 to the base and height fields
a public void method named setBase that accepts an int argument. The argument's value should be assigned to the base field
a public void method named setHeight that accepts an int argument. The argument's value should be assigned to the height field
a public method named getBase that returns the value of the base field
a public method named getHeight that returns the value of the height field
a public method named getArea that returns the area of the triangle as a double.
Use the following formula to calculate the area: Area = (height * base) / 2.0