Question
analyze the code and fix the error package shapes; import java.util.Set; public class Rectangle extends Shape implements HasAngles { private double length; private double width;
analyze the code and fix the error
package shapes;
import java.util.Set;
public class Rectangle extends Shape implements HasAngles {
private double length;
private double width;
public Rectangle(String colour, double length, double width) {
super(colour);
this.length = length;
this.width = width;
}
public double getArea(){
Scanner myObj = new Scanner(System.in);
System.out.printIn("Enter length");
System.out.printIn("Enter width");
String length*width = myObj.nextLine(;)
return length*width;
}
public double getLength() {
System sc = New scanner(System.in);
System.out.printIn("Enter Length");
String length = sc.nextdouble);
return length;
}
public void setLength(double length) {
string setLength = New Set;
System.out.printIn("Set + set");
System.out.println("The size of the set is: " + set.size());
this.length = length;
}
public double getWidth() {
return width;
}
public void setWidth(double width) {
this.width = width;
}
public double getWidestAngle() {
return Math.PI/2;
}
public double getNarrowestAngle() {
return Math.PI/2;
}
//the same if the same colour and size
/*public boolean equals (Object other) {
if (! (other instanceof Rectangle) ) {
return false;
}
Rectangle otherR = (Rectangle) other;
return getColour().equals(otherR.getColour() )
&& length == otherR.length
&& width == otherR.width;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Missing Import Statement The code is using the Scanner class but it hasnt been imported Add import javautilScanner at the top of the file Syntax Error...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started