Computers and Technology

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(){
}
}

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 09:40, vanessacasillas452
In the lab, which of the following displayed a list of all installed services and included a description of the service, the current state, and whether the service started automatically or manually? a. the services manager b. the applications summary c. the recommended services d. list the safe services list
Answers: 2
image
Computers and Technology, 22.06.2019 10:40, StephiUnicorni
When running anti-virus software , what could be a reason where recipitent is not guaranteed that data being streamed will not get interrupted?
Answers: 1
image
Computers and Technology, 24.06.2019 01:30, shonnybenskin8
Hazel has just finished adding pictures to her holiday newsletter. she decides to crop an image. what is cropping an image?
Answers: 1
image
Computers and Technology, 24.06.2019 10:00, zlittleton2008
Which feature of a blog to restore and retrieve older post
Answers: 3
Do you know the correct answer?
In this exercise, we are going to model some behaviors of a square. Since the Square object extends...

Questions in other subjects:

Konu
Physics, 29.04.2021 03:30
Konu
Mathematics, 29.04.2021 03:30
Konu
Mathematics, 29.04.2021 03:30