forked from ISPGroup/Term-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBookRecord.java
202 lines (185 loc) · 4.38 KB
/
BookRecord.java
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/**
* The purpose of this class is to store all the records.
* <p>
* @author David Yeghshatan
* @version Version 1 May 13
* <p>
* @param title The string that holds the book title.
* @param author The string that holds the author's name.
* @param genre The string that holds the genre.
* @param location The string that holds the location of the book.
* @param borrowDate Stores the date the book was borrowed if it is borrowed.
* @param returnDate Stores the date the book will be returned if it is borrowed.
* @param recNum Keeps track of the number of records.
*/
public class BookRecord
{
/**
* The string that holds the book title.
*/
private String title;
/**
* The string that holds the author's name.
*/
private String author;
/**
* The string that holds the genre.
*/
private String genre;
/**
* The string that holds the location of the book.
*/
private String location;
/**
* Stores the date the book was borrowed if it is borrowed.
*/
private String borrowDate;
/**
* Stores the date the book will be returned if it is borrowed.
*/
private String returnDate;
/**
* Keeps track of the number of records.
*/
public static int recNum = 0;
/**
* This class constructor creates new instance of BookRecord with 4 String parameters.
*
* @param title The user entered title
* @param author The user entered author name
* @param genre The user entered genre
* @param location The user entered location number
*/
public BookRecord (String title, String author, String genre, String location, String borrowDate, String returnDate)
{
this.title = formatName (title);
this.author = formatName (author);
this.genre = genre;
this.location = location;
this.borrowDate = borrowDate;
this.returnDate = returnDate;
recNum ++;
}
/**
* This class constructor creates new instance of BookRecord without any parameters.
*/
public BookRecord ()
{
recNum ++;
}
/**
* This method sets a new title.
*
* @param newName String the new title to be set.
*/
public void setTitle (String newName)
{
title = formatName (newName);
}
/**
* This method sets a new author name.
*
* @param newName String the new author name to be set.
*/
public void setAuthor (String newAuthor)
{
author = formatName (newAuthor);
}
/**
* This method sets a new genre.
*
* @param newName String the genre to be set.
*/
public void setGenre (String newGenre)
{
genre = newGenre;
}
/**
* This method sets a new location.
*
* @param newName String the location to be set.
*/
public void setLocation (String newLocation)
{
location = newLocation;
}
/**
* This method sets a new borrow date.
*
* @param newDate String the date to be set.
*/
public void setBorrowDate (String newDate)
{
borrowDate = newDate;
}
/**
* This method sets a new return date.
*
* @param newDate String the date to be set.
*/
public void setReturnDate (String newDate)
{
returnDate = newDate;
}
/**
* This method returns the current title.
*/
public String getTitle()
{
return title;
}
/**
* This method returns the current author name.
*/
public String getAuthor()
{
return author;
}
/**
* This method returns the current genre.
*/
public String getGenre ()
{
return genre;
}
/**
* This method returns the current location.
*/
public String getLocation ()
{
return location;
}
/**
* This method returns the current borrow date.
*/
public String getBorrowDate ()
{
return borrowDate;
}
/**
* This method returns the current return date.
*/
public String getReturnDate ()
{
return returnDate;
}
/**
* This method formats the inputted name.
*
* @param name String the name to be formatted.
* @param firstLetter String holds the first letter.
* @param theRest String holds the rest of the string.
* @return the formatted name.
*/
private String formatName (String name)
{
if (!(name.equals ("")||name.equals ("null")))
{
String firstLetter = Character.toString(name.charAt(0));
String theRest = name.substring(1, name.length());
return (firstLetter.toUpperCase() + theRest);
}
else
return (name);
}
}