Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
executable file
·
38 lines (27 loc) · 1.01 KB

File metadata and controls

executable file
·
38 lines (27 loc) · 1.01 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package howobjectsbehave;
public class HoopWithEquals extends Hoop {
public HoopWithEquals(int xin, int yin, int d, int t) {
super(xin, yin, d, t);
}
public boolean equals(HoopWithEquals w) {
return (getDiameter() == w.getDiameter() &&
getThickness() == w.getThickness());
}
public HoopWithEquals clone() {
int outerDiameter = getDiameter();
int innerDiameter = outerDiameter - 2 * getThickness();
return new HoopWithEquals(getX(), getY(), outerDiameter, innerDiameter);
}
public static void main(String[] args) {
// Create a hoop
HoopWithEquals hoop = new HoopWithEquals(100, 66, 90, 20);
// An identical hoop, but a different object
HoopWithEquals hoop1 = hoop.clone();
System.out.println("hoop1 == hoop? " + (hoop1 == hoop) + "\t"
+ "hoop1.equals(hoop)? " + hoop1.equals(hoop));
// Point hoop1 to same object that hoop refers to
hoop1 = hoop;
System.out.println("hoop1 == hoop? " + (hoop1 == hoop) + "\t"
+ "hoop1.equals(hoop)? " + hoop1.equals(hoop));
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.