-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibrary.java
More file actions
59 lines (44 loc) · 1.24 KB
/
Library.java
File metadata and controls
59 lines (44 loc) · 1.24 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
public class Library {
private Items items;
private Users users;
private User currentUser;
public Library() {
items = Items.getInstance();
users = Users.getInstance();
}
//creates a new user account
public boolean createAccount(String userName, String firstName, String lastName, int age, String phoneNumber)
{
return users.addUser(userName, firstName, lastName, age, phoneNumber);
}
public boolean login(String userName) {
if(!users.haveUser(userName))return false;
currentUser = users.getUser(userName);
return true;
}
public User getCurrentUser() {
return currentUser;
}
//Returns true if item is found, and false otherwise
public boolean findItem(String itemName) {
return items.haveItem(itemName);
}
public boolean checkout(String itemName) {
if(!findItem(itemName))return false;
//checkout the item
//need a user then have them checkout an item
return true;
}
public boolean rateItem(String itemName, int rating) {
if(!findItem(itemName))return false;
if(rating < 0 || rating > 5) return false;
return true;
}
public boolean payFine(int amount) {
if(amount < 0) return false;
return true; //successfully paid fine
}
public void logout() {
users.saveUsers();
}
}