-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReference.java
More file actions
109 lines (100 loc) · 3.42 KB
/
Copy pathReference.java
File metadata and controls
109 lines (100 loc) · 3.42 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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Assignment2;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Darko
*/
public abstract class Reference implements Ireferences{
private String callNumber;
private String title;
private int year;
public boolean setCallNumber(String callNumber) {
if( callNumber == null || callNumber.isEmpty() ) {
return false;
} else {
this.callNumber = callNumber;
return true;
}
}
public boolean setTitle(String title) {
if( title == null || title.isEmpty() ) {
return false;
} else {
this.title = title;
return true;
}
}
public boolean setYear(int year) {
if( year <1000 || year > 9999 ) {
return false;
} else {
this.year = year;
return true;
}
}
public String getCallNumber() {
return callNumber;
}
public String getTitle() {
return title;
}
public int getYear() {
return year;
}
@Override
public boolean keyEquals(Book other) {
if( other == null )
return false;
else
return getCallNumber().equalsIgnoreCase(other.getCallNumber()) &&
getYear() == other.getYear();
}
@Override
public boolean keyEquals(Journal other) {
if( other == null )
return false;
else
return getCallNumber().equalsIgnoreCase(other.getCallNumber()) && getYear() == other.getYear();
}
public static void catalogItem(String fileName, String type, String callnumber, int year, String publisher, String title, String authors){
PrintWriter catalog;
try {
catalog = new PrintWriter(new BufferedWriter(new FileWriter(fileName, true)));
catalog.println("type = " + "\"" + type + "\"");
catalog.println("callnumber = " + "\"" + callnumber + "\"");
catalog.println("authors = " + "\"" + authors + "\"");
catalog.println("title = " + "\"" + title + "\"");
catalog.println("publisher = " + "\"" + publisher + "\"");
catalog.println("year = " + "\"" + year + "\"");
catalog.println("\n");
catalog.close();
} catch (IOException ex) {
Logger.getLogger(Reference.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static void catalogItem(String fileName, String type, String callnumber, int year, String organizer, String title){
PrintWriter catalog;
try {
catalog = new PrintWriter(new BufferedWriter(new FileWriter(fileName, true)));
catalog.println("type = " + "\"" + type + "\"");
catalog.println("callnumber = " + "\"" + callnumber + "\"");
catalog.println("title = " + "\"" + title + "\"");
catalog.println("organization = " + "\"" + organizer + "\"");
catalog.println("year = " + "\"" + year + "\"");
catalog.println("\n");
catalog.close();
} catch (IOException ex) {
Logger.getLogger(Reference.class.getName()).log(Level.SEVERE, null, ex);
}
}
}