-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTitles.java
More file actions
179 lines (161 loc) · 3.59 KB
/
Copy pathTitles.java
File metadata and controls
179 lines (161 loc) · 3.59 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
package Project1;
public abstract class Titles implements Comparable<Titles> {
protected String titles[];
//Data Members
protected String callNumber;
protected String title;
protected String publisher;
protected int year;
protected int copies;
//Constructors
/**
* Default constructor
*/
public Titles()
{
callNumber = "";
title = "";
publisher = "";
year = 0;
copies = 0;
}
/**
* Constructor with parameters(call number, title, publisher, year, and copies)
* @param c value for data member call number
* @param t value for data member title
* @param p value for data member publisher
* @param y value for data member publish year
* @param copies value for data member copies
*/
public Titles(String c, String t, String p, int y, int copies)
{
callNumber = c;
title = t;
publisher = p;
year = y;
this.copies = copies;
}
//Getter Methods
/**
* Getter for the call number of a title
* @return value of data member callNumber
*/
public String getCallNumber()
{
return callNumber;
}
/**
* Getter for the title of a title
* @return value of data member title
*/
public String getTitle()
{
return title;
}
/**
* Getter for the publisher of a title
* @return value of data member publisher
*/
public String getPublisher()
{
return publisher;
}
/**
* Getter for the year of a title
* @return value of data member year
*/
public int getYear()
{
return year;
}
/**
* Getter for the copies of a title
* @return value of data member copies
*/
public int getCopies()
{
return copies;
}
//Setter Methods
/**
* Setter for the call number of a title
* @param c to set the data member callNumber
*/
public void setCallNumber(String c)
{
callNumber = c;
}
/**
* Setter for the title of a title
* @param t to set the data member title
*/
public void setTitle(String t)
{
title = t;
}
/**
* Setter for the publisher of a title
* @param p to set the data member publisher
*/
public void setPublisher(String p)
{
publisher = p;
}
/**
* Setter for the year of a title
* @param year to set the data member year
*/
public void setYear(int year)
{
this.year = year;
}
/**
* Setter for the copies of a title
* @param c to set the data member copies
*/
public void setCopies(int c)
{
copies = c;
}
/**
* Check if a title is restorable
* If a title is more than 20 years old, it's restorable
* @return whether the title is restorable or not
*/
public boolean isRestorable()
{
if(this.getYear() < 2002) //more than 20 years
return true;
return false;
}
/**
* Method to get the Title information
* @return formatted string containing the value of the data members
*/
public String toString()
{
return String.format("%-13s\t%-45s\t%-22s\t%4d", callNumber, title, publisher, year);
}
/**
* Method to get the Title information
* @return formatted string with each data member on its own line
*/
public String simpleString()
{
String output = "Call Number: " + callNumber;
output += "\nTitle: " + title;
output += "\nPublisher: " + publisher;
output += "\nYear: " + year;
output += "\nCopies: " + copies;
return output;
}
/**
* Compare method to help sorting based by year
* @param t given object to compare with
* @return the difference between current title and given title
*/
public int compareTo(Titles t)
{
return this.getYear() - t.getYear();
}
}