-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathTwoDShape9.java
60 lines (49 loc) · 1.15 KB
/
TwoDShape9.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.guide.c7;
abstract class TwoDShape9 {
private double width;
private double height;
private String name;
// A default constructor.
TwoDShape9() {
width = height = 0.0;
name = "none";
}
// Parameterized constructor.
TwoDShape9(double w, double h, String n) {
width = w;
height = h;
name = n;
}
// Construct object with equal with and height
TwoDShape9(double x, String n) {
width = height = x;
name = n;
}
// Construct an object from an object.
TwoDShape9(TwoDShape9 ob) {
width = ob.width;
height = ob.height;
name = ob.name;
}
// Accessor methods for with and height.
double getWidth() {
return width;
}
double getHeight() {
return height;
}
void setWidth(double w) {
width = w;
}
void setHeight(double h) {
height = h;
}
String getName() {
return name;
}
void showDim() {
System.out.println("Width and height are " + width + " and " + height);
}
// Now, area() is abstract.
abstract double area();
}