Computers and Technology

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

}
}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:10, o10922025
Assume that to_the_power_of is a function that expects two int parameters and returns the value of the first parameter raised to the power of the second parameter. write a statement that calls to_the_power_of to compute the value of cube_side raised to the power of 3 and that associates this value with cube_volume.
Answers: 1
image
Computers and Technology, 23.06.2019 13:30, juliajordan427
Best laptops for college [$100-$500 range]?
Answers: 2
image
Computers and Technology, 23.06.2019 17:00, solizpaco7124
1. which of the following is not an example of an objective question? a. multiple choice. b. essay. c. true/false. d. matching 2. why is it important to recognize the key word in the essay question? a. it will provide the answer to the essay. b. it will show you a friend's answer. c. it will provide you time to look for the answer. d. it will guide you on which kind of answer is required.
Answers: 1
image
Computers and Technology, 24.06.2019 05:30, roderickhinton
Someone plzz me which of these defines a social search? a. asking a search engine a question that is answered by a real person on the other sideb. modifying search results based on popularity of a web pagec. modifying search results based on a ranking of a web page
Answers: 2
Do you know the correct answer?
Squares - Javascript In this exercise, we are going to model some behaviors of a square. Since the...

Questions in other subjects:

Konu
Mathematics, 30.09.2019 19:00