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 19:10
10. when you create a pivottable, you need to specify where to find the data for the pivottable. is it true
Answers: 2
question
Computers and Technology, 22.06.2019 22:20
Pp 4.1 design and implement a class called sphere that contains instance data that represents the sphere’s diameter. define the sphere constructor to accept and initialize the diameter and include getter and setter methods for the diameter. include methods that calculate and return the volume and surface area of the sphere (see pp 3.5 for the formulas). include a tostring method that returns a one-line description of the sphere. create a driver class called multisphere, whose main method instantiates and updates several sphere objects.
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
How do you write an argumentative essay about the importance of free enterprise ?
Answers: 1
question
Computers and Technology, 23.06.2019 09:00
Design a class tictactoe that: holds the following information about the game: two-dimensional array (3 by 3), and winner. add additional variables as needed. includes the functions to perform the various operations on objects. for example, function to print the board, getting the move, checking if move is valid, determining if there is a winner after each move. add additional operations as needed. includes constructor(s). write the functions of the class, and write a program that uses the class. the program should declare an object of type tictactoe. the program will create the board and store it in the array. the program will allow two players to play the tic-tac-toe game. after every valid move update the array, check if there is a winner. if there is no winner and no tie, then print the board again to continue.
Answers: 2
You know the right answer?
PLZ HELP ASAP
package lesson8;

public abstract class Shape {
protected int h...
Questions
question
Computers and Technology, 29.08.2019 02:30
question
Computers and Technology, 29.08.2019 02:30
Questions on the website: 13722362