-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathTwoDShape7.java
50 lines (40 loc) · 958 Bytes
/
TwoDShape7.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
package com.guide.c7;
// A multilevel hierarchy.
public class TwoDShape7 {
private double width;
private double height;
// A default constructor.
TwoDShape7() {
width = height = 0.0;
}
// Parameterized constructor.
TwoDShape7(double w, double h) {
width = w;
height = h;
}
// Construct object with equal with and height
TwoDShape7(double x) {
width = height = x;
}
// Construct an object from an object.
TwoDShape7(TwoDShape7 ob) {
width = ob.width;
height = ob.height;
}
// 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;
}
void showDim() {
System.out.println("Width and height are " + width + " and " + height);
}
}