Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- public class Rectangle extends Point {
- private int width;
- private int height;
- private Color color;
- public Rectangle() {
- super(2, 0, 3);
- width = 3;
- height = 5;
- color = Color.ORANGE;
- }
- public Rectangle(int width, int height, int length, Color color) {
- super((int) Math.ceil((double) width / 2),
- (int) Math.ceil((double) length / 2),
- (int) Math.ceil((double) height / 2));
- this.width = width;
- this.height = length;
- this.color = color;
- }
- public Rectangle(int newX, int newY, int newWidth, int newHeight) {
- super(newX, newY, 0);
- width = newWidth;
- height = newHeight;
- }
- public void setWidth(int width) {
- this.width = width;
- setZ((int) Math.ceil((double) height / 2));
- }
- public void setHeight(int height) {
- this.height = height;
- setZ((int) Math.ceil((double) height / 2));
- }
- public int getWidth() {
- return width;
- }
- public int getHeight() {
- return height;
- }
- public int calcArea() {
- return width * height;
- }
- public DrawFigure drawFigure() {
- DrawFigure rectangle1 = new DrawFigure(1, width, height, 0);
- return rectangle1;
- }
- public String toString() {
- return "Width = " + width + " Height = " + height + "\n" + color + "\nCenter: " + super.toString();
- }
- public int calcVolume() {
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement