Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help! import java.awt.Color; public class Shape { private int x; private int y; private Color color; public Shape(int x, int y, Color color) {

Please help!

image text in transcribed

import java.awt.Color;

public class Shape {

private int x;

private int y;

private Color color;

public Shape(int x, int y, Color color) {

this.x = x;

this.y = y;

this.color = color;

}

public Color getColor() {

return color;

}

public int getX() {

return x;

}

public int getY() {

return y;

}

public void setColor(Color color) {

this.color = color;

}

Please give solution with comments and explanations showing steps.

2) Suppose that the following Shape class has been declared import java.awt.Color; public class Shape[ private int x; private int y; private Color color; public Shape (int x, int y, Color color) this . x x; this . y = y; this.colorcolor; public Color getColor) return color; public int getX) [ return x public int getY 0 return Y: public void setColor (Color color) this. color color; . Add an instance method named area to the Shape class, which will return the area (double) of a shape. Note: please use x*y to calculate the area of a shape .Define a Triangle class by extending the Shape class. A Triangle object will represent eral triangle, so the Triangle class will need only instance variable, Which an will store the length of one of the triangle's class . Override the instance method area in Triangle by using following equations Area = p(p-a)(p-b)(p-c) a + b+ (c where p is half the perimeter,or . Add toString methods to the Shape and Triangle classe:s The version of toString in the Shape class will return a string of the form "Position: (10.50) Color:(r=64,b=192,g-255)" The version of toString in the Triangle class will return a string of the form "Postition: (10,50) Side Length: (5) Color(r-64,b=192,g-255)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Solve. Give exact solutions. y 4 - 3y 2 + 1 = 0

Answered: 1 week ago