GoConqr has a new look! Let us know what you think.

Notes

Superclass Example 2

joannazhang13 English 1 page

Content of the notes (1)

Page 1

public class Square extends Shape

{

private double length;

//constructor

public Square (double l, String name)

{

super(name);

length=l;

}

public double getLength()

{

return length;

}

public double perimeter()

{

return length*4;

}

public double area()

{

return length*length;

}

public int compareTo(Shape s)

{

if (s.getName()==name

{

if(s.area()==area())

return 0;

else if (s.area()>area())

return -1;

else

return 1;

}

else

return -2;

}

}

Information

Description
Example code of java superclass
Created by
joannazhang13 · May 2015
Updated
Feb 19, 2016
Views
36
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?