forked from BruceEckel/OnJava8-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDepthReading.java
More file actions
29 lines (28 loc) · 763 Bytes
/
DepthReading.java
File metadata and controls
29 lines (28 loc) · 763 Bytes
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
// references/DepthReading.java
// (c)2017 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
// Cloning a composed object
package references;
public class DepthReading implements Cloneable {
private double depth;
public DepthReading(double depth) {
this.depth = depth;
}
@Override
public DepthReading clone() {
try {
return (DepthReading)super.clone();
} catch(CloneNotSupportedException e) {
throw new RuntimeException(e);
}
}
public double getDepth() { return depth; }
public void setDepth(double depth) {
this.depth = depth;
}
@Override
public String toString() {
return String.valueOf(depth);
}
}