Superclass Example 2

Beschreibung

Example code of java superclass
joannazhang13
Notiz von joannazhang13, aktualisiert more than 1 year ago
joannazhang13
Erstellt von joannazhang13 vor mehr als 9 Jahre
8
0

Zusammenfassung der Ressource

Seite 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; } }

Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

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