subject

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: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 04:30, zetrenne73
How can you know if the person or organization providing the information has the credentials and knowledge to speak on this topic? one clue is the type of web site it is--the domain name ".org" tells you that this site is run by a nonprofit organization.
Answers: 2
image
Computers and Technology, 22.06.2019 11:00, kingethan08
Ihave an iphone 8plus should i get another phone like samsung note 9 or s9 ? ?
Answers: 2
image
Computers and Technology, 22.06.2019 23:30, Molly05
In my email i got a message it says a quick message and in message details on who its from its says nicole and under nicole is 50e0bf08e5b671@ualwgypg91wa5wl. uzo9kbud3qjwddygd5.vng -
Answers: 1
image
Computers and Technology, 23.06.2019 01:50, rhonda45801
Free points just awnser this. what should i watch on netflix
Answers: 2
You know the right answer?
In this exercise, we are going to model some behaviors of a square. Since the Square object extends...

Questions in other subjects:

Konu
English, 07.12.2020 22:00
Konu
Spanish, 07.12.2020 22:00