3
Copyright (c) Xerox Corporation 1998-2002. All rights reserved.
5
Use and copying of this software and preparation of derivative works based
6
upon this software are permitted. Any distribution of this software or
7
derivative works must comply with all applicable United States export control
10
This software is made available AS IS, and Xerox Corporation makes no warranty
11
about the software, its performance or its conformity to any specification.
13
|<--- this code is formatted to fit into 80 columns --->|
14
|<--- this code is formatted to fit into 80 columns --->|
15
|<--- this code is formatted to fit into 80 columns --->|
23
* Square is a 2D shape. It extends the TwoDShape class with the side
24
* variable, and it implements TwoDShape's abstract methods for
25
* correctly computing a square's area and distance.
28
public class Square extends TwoDShape {
29
protected double s; // side
32
* All sorts of constructors
34
public Square(double x, double y, double s) {
35
super(x, y); this.s = s;
38
public Square(double x, double y) {
42
public Square(double s) {
51
* Returns the perimeter of this square
53
public double perimeter() {
58
* Returns the area of this square
60
public double area() {
65
* This method overrides the one in the superclass. It adds some
66
* circle-specific information.
68
public String toString() {
69
return ("Square side = " + String.valueOf(s) + super.toString());