forked from mvolkmann/mvolkmann.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArtist.java.html
More file actions
67 lines (55 loc) · 1.73 KB
/
Copy pathArtist.java.html
File metadata and controls
67 lines (55 loc) · 1.73 KB
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
61
62
63
64
65
66
67
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR.html1/DTD.html1-transitional.dtd">
<html xmlns="http://www.w3.org/1999.html">
<head>
<title>Artist.java</title>
<link rel="stylesheet" type="text/css" href="../../common.css"/>
</head>
<body>
<h2>Artist.java</h2>
<pre><div class="code">package com.ociweb.demo;
import com.ociweb.lang.ObjectUtil;
import java.util.*;
/**
* This is just a Java Bean.
*/
public class Artist {
private String name;
private List<Recording> recordings = new ArrayList<Recording>();
public Artist() {}
public Artist(String name) { this.name = name; }
public void addRecording(Recording recording) {
recordings.add(recording);
}
public Recording addRecording(String title, int year) {
Recording r = new Recording(this, title, year);
addRecording(r);
return r;
}
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj == this) return true;
if (!(obj instanceof Artist)) return false;
Artist a = (Artist) obj;
return ObjectUtil.equals(name, a.name) &&
recordings.equals(a.recordings);
}
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public List<Recording> getRecordings() { return recordings; }
public void setRecordings(List<Recording> recordings) {
this.recordings = recordings;
}
public String toString() {
String s = "Artist: " + name;
for (Recording r : recordings) { s += "\n " + r; }
return s;
}
}</div></pre>
<hr/>
<p style="text-align:center">
Copyright © 2007 Object Computing, Inc. All rights reserved.
</p>
</body>
</html>