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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 02:30, jaueuxsn
Which component acts as a platform on which application software runs
Answers: 2
image
Computers and Technology, 23.06.2019 08:30, mai1261
Helen's credit card has an apr of 15.32% and a grace period of 17 days and helen pays her balance in the full every month. if her last billing cycle ended on september 26, 2009, and she made her payment on october 11, 2009, did she owe any interest on her last statement's balance?
Answers: 3
image
Computers and Technology, 23.06.2019 16:30, azainababbas
20 points archie wants to use a reflector as he photographs a newlywed couple. what would he consider in his choice? a. shadow and sunny b. homemade and professional c. lamps and boards d. incident and reflected e. neutral density and enhancement
Answers: 3
image
Computers and Technology, 25.06.2019 01:30, kalag9478
If the average computer chip had 1,200 transistors per square inch in 1970, approximately how many transistors per square inch would one have in 1976? use moore's law to calculate your answer
Answers: 1
You know the right answer?
PLZ HELP ASAP
package lesson8;

public abstract class Shape {
protected int h...

Questions in other subjects:

Konu
English, 28.11.2019 19:31
Konu
Mathematics, 28.11.2019 19:31