subject

PLZ HELP ASAP
package lesson8;

public abstract class Shape {
protected int height;
protected int width;

public Shape(int height, int width) {
this. height = height;
this. width = width;
}

public final void printArea() {
System. out. println("This " + getName() + " has a height of " +
height + ", a width of " + width + ", and an area of " +
getArea() + ".");
}

public final void printPerimeter() {
System. out. println("This " + getName() + " has a height of " +
height + ", a width of " + width + ", and a perimeter of " +
getPerimeter() + ".");
}

protected abstract String getName();
protected abstract double getArea();
protected abstract double getPerimeter();
}
Rectangle Class
package lesson8;

public class Rectangle extends Shape {
public Rectangle(int height, int width) {
super(height, width);
}

protected String getName() {
return "rectangle";
}

protected double getArea() {
return height * width;
}

protected double getPerimeter() {
return height * 2 + width * 2;
}
}
RightTriangle Class
package lesson8;

public class RightTriangle extends Shape {
public RightTriangle(int height, int width) {
super(height, width);
}

protected String getName() {
return "right triangle";
}

protected double getArea() {
return height * width / 2;
}

protected double getPerimeter() {
return height + width + Math. sqrt(height * height + width * width);
}
}
Square Class
package lesson8;

public class Square extends Rectangle {
public Square(int height) {
super(height, height);
}

protected String getName() {
return "square";
}
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:20
Avariable of the data type arrays is storing 10 quantities. what is true about these quantities? a. the quantities all have different characteristics. b. the quantities all have the same characteristics. c. five quantities have the same and five have different characteristics. d. it is necessary for all quantities to be integers. e. it is necessary for all quantities to be characters.
Answers: 2
question
Computers and Technology, 23.06.2019 08:00
Match the items with their respective descriptions.
Answers: 1
question
Computers and Technology, 23.06.2019 15:20
What does a bonus object do? a. subtracts lives b. keeps track of a player's health c. gives a player an advantage d. makes text appear
Answers: 1
question
Computers and Technology, 23.06.2019 17:30
Scientists have changed the model of the atom as they have gathered new evidence. one of the atomic models is shown below. what experimental evidence led to the development of this atomic model from the one before it? a few of the positive particles aimed at a gold foil seemed to bounce back. the colors of light emitted from heated atoms had very specific energies. experiments with water vapor showed that elements combine in specific proportions. cathode rays were bent in the same way whenever a magnet was brought near them.
Answers: 2
You know the right answer?
PLZ HELP ASAP
package lesson8;

public abstract class Shape {
protected int h...
Questions
question
Mathematics, 24.08.2021 05:00
question
Mathematics, 24.08.2021 05:00
Questions on the website: 13722363