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:20
Pp 4.1 design and implement a class called sphere that contains instance data that represents the sphere’s diameter. define the sphere constructor to accept and initialize the diameter and include getter and setter methods for the diameter. include methods that calculate and return the volume and surface area of the sphere (see pp 3.5 for the formulas). include a tostring method that returns a one-line description of the sphere. create a driver class called multisphere, whose main method instantiates and updates several sphere objects.
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
You are consulting for a beverage distributor who is interested in determining the benefits it could achieve from implementing new information systems. what will you advise as the first step?
Answers: 1
question
Computers and Technology, 23.06.2019 07:10
If you want to import a picture into a dtp application, what must you do first? draw an image frame. import text. open the folder containing the file. select get image… from the windows menu.
Answers: 2
question
Computers and Technology, 23.06.2019 17:30
When making changes to optimize part of a processor, it is often the case that speeding up one type of instruction comes at the cost of slowing down something else. for example, if we put in a complicated fast floating-point unit, that takes space, and something might have to be moved farther away from the middle to accommodate it, adding an extra cycle in delay to reach that unit. the basic amdahl's law equation does not take into account this trade-off. a. if the new fast floating-point unit speeds up floating-point operations by, on average, 2ă—, and floating-point operations take 20% of the original program's execution time, what is the overall speedup (ignoring the penalty to any other instructions)? b. now assume that speeding up the floating-point unit slowed down data cache accesses, resulting in a 1.5ă— slowdown (or 2/3 speedup). data cache accesses consume 10% of the execution time. what is the overall speedup now? c. after implementing the new floating-point operations, what percentage of execution time is spent on floating-point operations? what percentage is spent on data cache accesses?
Answers: 2
You know the right answer?
Squares - Javascript In this exercise, we are going to model some behaviors of a square. Since the...
Questions
question
Mathematics, 04.09.2019 00:10
question
Mathematics, 04.09.2019 00:10
question
Mathematics, 04.09.2019 00:10
Questions on the website: 13722367