Question: public class Store { public static ArrayList users; / / creating the array lists. public static ArrayList storeitems; / / a method to save array

publicclassStore{
publicstaticArrayListusers;// creating the array lists.
publicstaticArrayListstoreitems;
// a method to save array list to file
publicstaticvoidsaveInfo(ArrayListusers,ArrayListstoreitems,Stringbagstore)
throwsIOException{
FileWriteref=null;
try{
ef=newFileWriter(bagstore);
for(Usersu:users){
ef.write(u.toString());
ef.write(System.lineSeparator());
}
ef.write(System.lineSeparator());
ef.write("--------------------");
ef.write(System.lineSeparator());
for(StoreItemss:storeitems){
ef.write(s.toString());
ef.write(System.lineSeparator());
}
}finally{
if(ef!=null){
ef.close();
}
}
}
// checking the users id and password
publicstaticUsersauthenticate(intId,StringName,Stringpassword){
for(Usersuser:users){
if(user.getId()==Id&&user.equals(Name)&&user.Password(password)){
returnuser;
}
}
returnnull;
}
// checking the users id and password (customer)
publicstaticUsersauthenticate2(intId,StringName){
for(Usersuser:users){
if(user.getId()==Id&&user.equals(Name)){
returnuser;
}
}
returnnull;
}
// lists the items
publicstaticArrayListItemsByCategory(Stringcategory){
ArrayListByCategory=newArrayList<>();
for(StoreItemsItem:storeitems){
if(Item.getCategory().equals(category)){
ByCategory.add(Item);
}
}
returnByCategory;
}
// search an item
publicstaticArrayListsearchItems(Stringsearched){
ArrayListsearch=newArrayList<>();
for(StoreItemsItem:storeitems){
if(Item.getName().toLowerCase().contains(searched.toLowerCase())){
search.add(Item);
}
}
returnsearch;
}
// adds an item to the array list
publicstaticArrayListaddItem(Stringname,doubleprice,Stringcategory,Stringcolor){
StoreItemsadd=newStoreItems(name,price,category,color);
storeitems.add(add);
returnstoreitems;
}
// creates a new customer account
publicstaticArrayListcreateCustomerAcc(intId,StringName){
Userscustomer=newCustomer(Id,Name);
users.add(customer);
returnusers;
}
// adds a new user to the array list
publicstaticArrayListaddUser(intId,StringName){
Usersuser=newCustomer(Id,Name);
users.add(user);
returnusers;
}
// the user logging out method
publicstaticvoidlogOut(StringName){
System.out.printf("%s Logged out",Name);
}
}
convert it to gui code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!