import java.util.ArrayList; import java.lang.Integer; import java.util.Scanner; import java.util.Random; class work { // inventory management public static void main (String [] args) { ArrayList<KuCun> list=new ArrayList<KuCun>(); B1 KuCun = new new KuCun (); B2 KuCun = new new KuCun (); B3 KuCun = new new KuCun (); // All brands b1.brand = "MacbookAir" ; b2.brand="ThinkPadT450"; b3.brand = "ASUS-FL5800" ; // All dimensions b1.size = 13.3 ; b2.size=14.0; b3.size = 15.6 ; // all inventory b1.num = 5 ; b2.num = 10 ; b3.num = 18 ; // All prices b1.price = 6988.88 ; b2.price=5999.99; b3.price=4999.5; list.add(b1); list.add(b2); list.add(b3); show(list); } // performs encapsulation public static void Show (the ArrayList <KuCun> List) { Scanner sc=new Scanner(System.in); while(true){ System.out.println ( "Inventory Management ---------------- ----------------" ); System.out.println ( "1. Check inventory" ); System.out.println ( "2. Modify the number of commodity stocks" ); System.out.println ( "3. Exit" ); System.out.println("----------------------------------------"); System.out.println ( "Please input operation number to be performed:" ); int in = sc.nextInt (); Switch (in) { Case . 1 : look(list); break; case 2: select(list); BREAK ; Case 3 : return ; // BREAK AA; return: the return call my local default : System.out.println("----------------------------------------"); System.out.println ( "Please enter the correct operation of the serial number!" ); System.out.println("----------------------------------------"); break; } } } // print inventory functions public static void look (the ArrayList <KuCun> List) { int SUM = 0 ; int allSum = 0 ; System.out.println ( "brand \ t \ t size \ t inventory \ t price" ); System.out.println("----------------------------------------"); for(int i=0;i<list.size();i++){ sum+=list.get(i).num; allSum+=list.get(i).num*list.get(i).price; System.out.print(list.get(i).brand+"\t"+list.get(i).size+"\t"+list.get(i).num+"\t"+list.get(i).price); System.out.println(); } System.out.println ( "total inventory:" + SUM); System.out.println ( "The total amount of goods:" + allSum); } // Number of stock editing public static void SELECT (the ArrayList <KuCun> List) { System.out.println ( "Please enter the number you want to modify the product" ); for ( int I = 0; I <list.size (); I ++ ) { System.out.print((i+1)+":"+list.get(i).brand); System.out.println(); } Scanner sc=new Scanner(System.in); int in=sc.nextInt(); while(true){ switch(in){ case 1: System.out.println ( "trade name:" + List.get (-in. 1 ) .brand); System.out.println ( "Please change the number of stocks" ); int the Add = sc.nextInt (); list.get(in-1).num=add; System.out.println ( "modified" + list.get (in-1) .brand + " stock is:" + the Add); System.out.println(); return; case 2: System.out.println ( "trade name:" + List.get (-in. 1 ) .brand); System.out.println ( "Please change the number of stocks" ); add=sc.nextInt(); list.get(in-1).num=add; System.out.println ( "modified" + list.get (in-1) .brand + " stock is:" + the Add); System.out.println(); return; case 3: System.out.println ( "trade name:" + List.get (-in. 1 ) .brand); System.out.println ( "Please change the number of stocks" ); add=sc.nextInt(); list.get(in-1).num=add; System.out.println ( "modified" + list.get (in-1) .brand + " stock is:" + the Add); System.out.println(); return; case 00: return; default: System.out.println ( "Please enter the correct item number" ); in=sc.nextInt(); break; } } } }
// custom class class KuCun { // All brands String Brand; // all sizes Double size; // all inventory int NUM; // All prices Double . Price; }