subject

Squares - Javascript In this exercise, we are going to model some behaviors of a square. Since the Square object extends the Rectangle object, we see that a lot of the information we need is stored in the superclass and we will need to access it using the super keyword. Your job is to complete the Square class, as specified within the class. Upon completion, thoroughly test out your code using the SquareTester class.
public class SquareTester
{
public static void main(String[] args)
{
Square square = new Square(5);
Rectangle rectangle = new Rectangle (5, 7);

System. out. println(square);
System. out. println(rectangle);
}
}

public class Rectangle
{

private double width;
private double height;

public Rectangle(double w, double h)
{
width = w;
height = h;
}

public double getWidth()
{
return width;
}

public void setWidth(double w)
{
width = w;
}

public double getHeight()
{
return height;
}

public void setHeight(double h)
{
height = h;
}

public double area()
{
return width * height;
}

public String toString(){
return "Rectangle with width " + width + " and height " + height;
}
}

public class Square extends Rectangle {

// Call to the Rectangle constructor
public Square(double sideLength){

}

// Return either the width or height from the superclass
public double getSideLength(){

}

//Set both the width and height in the superclass
public void setSideLength(double sideLength){

}

// Get the width and/or the height from the superclass
public double area(){

}

// Override to read: Square with side lengths
public String toString(){

}
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:30
You are new to microsoft certification and want to start out by getting a certification geared around windows 8. what microsoft certification should you pursue?
Answers: 1
question
Computers and Technology, 23.06.2019 18:30
List 3 items that were on kens resume that should have been excluded
Answers: 1
question
Computers and Technology, 24.06.2019 00:00
Which tool could be used to display only rows containing presidents who served two terms
Answers: 3
question
Computers and Technology, 24.06.2019 01:30
How can you make your column headings stand out?
Answers: 1
You know the right answer?
Squares - Javascript In this exercise, we are going to model some behaviors of a square. Since the...
Questions
question
History, 03.12.2020 01:00
question
Mathematics, 03.12.2020 01:00
Questions on the website: 13722360