Subclass Example

Descripción

Example code of java subclass
joannazhang13
Apunte por joannazhang13, actualizado hace más de 1 año
joannazhang13
Creado por joannazhang13 hace más de 9 años
18
0

Resumen del Recurso

Página 1

public class Rectangle extends Square{private double length;private double width;//constructorpublic Rectangle (double l, double w, String name){super(name);length=l;width= w;}public double getLength(){return length;}public double getWidth(){return width;}public double perimeter(){return (length+width)*2;}public double area(){return length*width;}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;}elsereturn -2;} }

Mostrar resumen completo Ocultar resumen completo

Similar

Java Week 5 Object Oriented Programming
Troy Bowlin
Abstract Class Quiz
joannazhang13
What does inheritance do?
joannazhang13
Abstract Class Example
joannazhang13
Superclass Example 1
joannazhang13
Let's see what you know
joannazhang13
Superclass Example 2
joannazhang13
Java Practice 1
Ummm No
Java Practice 2
Ummm No
Servion - Java Questionnaire
rohit.benedict
Java Core. Basics
Gadget