Answered step by step
Verified Expert Solution
Question
1 Approved Answer
how to covert this code to gui code ? import java.io . File; import java.io . FileWriter; import java.io . IOException; import java.util.ArrayList; import java.util.Arrays;
how to covert this code to gui code
import java.ioFile;
import java.ioFileWriter;
import java.ioIOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.ConcurrentModificationException;
import java.util.InputMismatchException;
import java.util.List;
import java.util.Scanner;
public class Main extends Store
public static void mainString args throws Exception, IOException
Scanner in new ScannerSystemin;
users new ArrayList;
adding the users to the array list
users.addnew Manager "owner", "owner";
users.addnew Manager "Nour", "Nour;
users.addnew Manager "Ranad", "Ranad;
users.addnew Employee "Sara", "Sara;
users.addnew Employee "Safa", "Safa;
users.addnew Customer "Rana";
users.addnew Customer "Rahma";
users.addnew Customer "Mona";
storeitems new ArrayList;
adding the items to the array list
storeitems.addnew StoreItemsMiniClutch "Clutchs", "Black";
storeitems.addnew StoreItemsBagClutch "Clutchs", "Black";
storeitems.addnew StoreItemsSchoolbackpack "Backpacks", "Red";
storeitems.addnew StoreItemsTravelbackpack "Backpacks", "Brown";
storeitems.addnew StoreItemsMiniTote "Totebags", "Silver";
storeitems.addnew StoreItemsLargeTote "Totebags", "Gold";
storeitems.addnew StoreItemsMiniCrosebody "Crosebody", "White";
storeitems.addnew StoreItemsMediumCrosebody "Crosebody", "Blue";
saving data in the created file.
String CarryAll "store.data";
try
Store.saveInfousers storeitems, CarryAll;
catch IOException e
the menu of the store
System.out.printlnMenu: ;
System.out.printlnLogin ;
System.out.printEnter your Choice: ;
int choice innextInt;
while choice
System.out.printinvaild choice.
Enter a valid choice: ;
choice innextInt;
String N;
while choice
System.out.printEnter ID: ; user interning the id
int id innextInt;
checking the id of the users
if id && id
System.out.printEnter Name: ;
N innext;
System.out.printEnter Password: ;
String Pass innext;
System.out.println;
authenticate the info. of the user.
do
if authenticateid N Pass null
System.out.printlnInvalid login information. Try again!";
System.out.printEnter ID: ;
id innextInt;
System.out.printEnter Name: ;
N innext;
System.out.printEnter Password: ;
Pass innext;
else
System.out.printlnauthenticateid N Pass;
while authenticateid N Pass null;
System.out.printfWelcome Manager s N;
System.out.println;
Displaying the menu to the user
System.out.print
"Menu:
Add new Customer Account.
RemoveUser.
Add Item.
Remove Item.
Update Item.
List Items.
Search Item.
Logout.
;
System.out.printEnter your Choice: ;
int cm innextInt;
checking the menu choice of the manager
while cm cm
if cm cm
System.out.printWrong choice!
Enter your choice again: ;
cm innextInt;
else
Switching between the cases of the menu
switch cm
case : creating a new customer acc.
try
System.out.printEnter the new customer Id:;
int Id innextInt;
System.out.printEnter the new cusnamer Name:";
String Name innext;
System.out.printlnCustomer is added.";
System.out.printcreateCustomerAccId Name;
catch NullPointerException InputMismatchException e
break;
case : removing user
try
System.out.printlnSelect the User you want to remove:";
System.out.println
owner owner
Nour, Nour
Ranad, Ranad
Sara, Sara
Safa, Safa
Rana
Rahma
Mona
Your Selection: ;
int r innextInt;
System.out.printlnusersremover;
System.out.printlnThe list after removing the User:
users;
System.out.printlnThe User is removed.";
catch NullPointerException InputMismatchException e
break;
case : adding items to the list
try
System.out.printEnter the Item name: ;
String name innext;
System.out.printEnter the Item price: ;
double price innextDouble;
System.out.printEnter the Item category: ;
String category innext;
System.out.printEnter the Item Color: ;
String color innext;
System.out.printlnThe item is added.";
System.out.printaddItemname price, category, color;
catch NullPointerException InputMismatchException e
break;
case : removing item from the list
try
System.out.printlnSelect the item you want to remove:";
System.out.println
MiniClutch Clutchs, Black
BagClutch Clutchs, Black
Schoolbackpack Backpacks, Red
Travelbackpack Backpacks, Brown
MiniTote Totebags, Silver
LargeTote Totebag
Step by Step Solution
There are 3 Steps involved in it
Step: 1
import javaawt import javaawtevent import javaxswing import javaio import javautilArrayList import javautilArrays import javautilList public class MainGUI extends JFrame private ArrayList users privat...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started