-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStore.java
More file actions
71 lines (65 loc) · 1.99 KB
/
Copy pathStore.java
File metadata and controls
71 lines (65 loc) · 1.99 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
/**
* Project 5 - Store.java
*
* Class that represents an individual store that belongs to a seller in the
* application.
*
* @author Shafer Anthony Hofmann, Qihang Gan, Shreyas Viswanathan, Nathan Pasic
* Miller, Oliver Long
*
* @version December 6, 2023
*/
public class Store {
private Database db = new Database();
private String storeIdentificationNumber;
private String storeName;
/**
* Creating a new store for the first time. Generates a unique ID and adds a
* signifier to it indicating that it is a store.
*
* @param storeName The new store's name
*/
public Store(String storeName) {
this.storeIdentificationNumber = "ST" + String.valueOf(generateStoreIdentificationNumber());
this.storeName = storeName;
}
/**
* Re-initialize an already-existing store
*
* @param storeIdentificationNumber The existing store's ID
* @param storeName The existing store's name
*/
public Store(String storeIdentificationNumber, String storeName) {
this.storeIdentificationNumber = storeIdentificationNumber;
this.storeName = storeName;
}
/**
* Gets the current store's ID
*
* @return The ID associated with this store
*/
public String getStoreIdentificationNumber() {
return this.storeIdentificationNumber;
}
/**
* Gets the current store's name
*
* @return The name associated with this store
*/
public String getStoreName() {
return this.storeName;
}
/**
* Returns a unique 7-digit ID as long as the current ID is not already
* associated with an existing account in the stores.csv database
*
* @return A unique 7-digit ID
*/
public int generateStoreIdentificationNumber() {
int currentID = 1000000; // The first store created will have this ID
while (db.checkIDMatch(currentID, "stores.csv")) {
currentID += 1;
}
return currentID;
}
}