You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
alert.setContentText("Your search did not match any results. Please try again.");
106
+
alert.setHeaderText("Not Found");
107
+
alert.showAndWait();
108
+
}
109
+
110
+
privatebooleanconfirmation(){
111
+
Alertalert = newAlert(Alert.AlertType.WARNING);
112
+
alert.setTitle("Confirm Part Removal");
113
+
alert.setContentText("Click 'Ok' to proceed.");
114
+
alert.setHeaderText("Are you sure you want to remove this part from the product?");
115
+
116
+
Optional<ButtonType> result = alert.showAndWait();
117
+
118
+
if (result.get() == ButtonType.OK) {
119
+
returntrue;
120
+
} else {
121
+
returnfalse;
122
+
}
123
+
}
124
+
125
+
voiderrorMessage(Stringcontent){
126
+
127
+
Alertalert = newAlert(Alert.AlertType.WARNING);
128
+
alert.setContentText(content);
129
+
alert.setHeaderText("Something went wrong.");
130
+
alert.showAndWait();
131
+
}
132
+
133
+
/*
134
+
* The search() method is a helper function that returns a boolean indicating whether an integer is already being used as an ID number for an existing product.
135
+
* This is only called in the generateID() method to ensure that the auto-generated ID is unique.
136
+
*
137
+
* @param id Integer to be checked for ID uniqueness
138
+
* @return boolean True if ID belongs to existing product, False otherwise
139
+
* */
140
+
privatebooleansearch(intid){
141
+
142
+
for(Productp : Inventory.getAllProducts())
143
+
{
144
+
if(p.getId() == id){
145
+
returntrue;
146
+
}
147
+
}
148
+
returnfalse;
149
+
}
150
+
151
+
/*
152
+
* The generateID() method is a helper function that generates an ID number for created part. Always returns the next unique integer in sequential order
153
+
*
154
+
* @return id Integer that is either 1 (if List is empty), or the next unique integer
155
+
* */
156
+
privateintgenerateID() {
157
+
158
+
intid = 1;
159
+
for(Parta : Inventory.getAllParts()) {
160
+
if(search(id)){
161
+
id++;
162
+
} else {
163
+
returnid;
164
+
}
165
+
}
166
+
returnid;
167
+
}
168
+
169
+
/*
170
+
* The isInt() method checks whether a provided string can be converted to an integer and returns a boolean.
171
+
*
172
+
* @param str The string to be checked
173
+
* @return boolean Returns true if string is also an integer, false if exception is caught
0 commit comments