weiqian1020

19/6/17

Jun 19th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 23.82 KB | None | 0 0
  1. package assignment;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Scanner;
  5.  
  6. public class core{
  7.     private static Scanner input;
  8.     private String account;
  9.     private ArrayList<String> username = new ArrayList<String>();
  10.     private ArrayList<String> password = new ArrayList<String>();
  11.     private ArrayList<String> userOrder = new ArrayList<String>();
  12.     private ArrayList<String> shipStatus = new ArrayList<String>();
  13.     private ArrayList<String> orderStatus = new ArrayList<String>();
  14.     private ArrayList<Top> top = new ArrayList<Top>();
  15.     private ArrayList<Pant> pant = new ArrayList<Pant>();
  16.     private ArrayList<Dress> dress = new ArrayList<Dress>();
  17.     private ArrayList<Skirt> skirt = new ArrayList<Skirt>();
  18.     Top tempT = new Top();
  19.     Pant tempP = new Pant();
  20.     Dress tempD = new Dress();
  21.     Skirt tempS = new Skirt();
  22.     public static void main(String[] args) {
  23.         int x = 0;
  24.         boolean bool = true;
  25.         core run = new core();
  26.         input = new Scanner(System.in);
  27.         do{
  28.             switch (x) {
  29.            
  30.             case 0:
  31.                 x = run.mainMenu();
  32.                 break;
  33.             case 1:
  34.                 x = run.admin();
  35.                 break;
  36.             case 2:
  37.                 x = run.user();
  38.                 break;
  39.             case 3:
  40.                 x = run.userLogin();
  41.                 break;
  42.             case 4:
  43.                 x = run.userReg();
  44.                 break;
  45.             case 5:
  46.                 x = run.userMenu();
  47.                 break;
  48.             case 6:
  49.                 x = run.userShop();
  50.                 break;
  51.             case 7:
  52.                 x = run.userStatus();
  53.                 break;
  54.             default:
  55.                 bool = false;
  56.                 System.out.println(x);
  57.                 break;
  58.             }
  59.         } while (bool);
  60.     }
  61.    
  62.     private int mainMenu(){
  63.         System.out.println("Welcome to FreeStyler Online Apparels");
  64.         System.out.println("Login As:\n(1)Admin\n(2)User");
  65.         boolean bool = true;
  66.         String n;
  67.         do {
  68.             try{
  69.                 n = input.nextLine();
  70.             } catch (Exception e) {
  71.                 System.out.println("Invalid input, " + e);
  72.                 System.out.println("Login As:\n(1)Admin\n(2)User");
  73.                 continue;
  74.             }
  75.             if (n.equals("1")){
  76.                 bool = false;
  77.                 return 1;
  78.             }
  79.             else if (n.equals("2")){
  80.                 bool = false;
  81.                 return 2;
  82.             }
  83.             else {
  84.                 System.out.println("Invalid input, please try again");
  85.                 System.out.println("Login As:\n(1)Admin\n(2)User");
  86.                 continue;
  87.             }
  88.         }while(bool);
  89.         return 0;
  90.     }
  91.     private int admin(){
  92.         boolean bool = true;
  93.         String user, pass = null;
  94.         do {
  95.             System.out.println("-1 to back");
  96.             System.out.print("Username: ");
  97.             try {
  98.                 user = input.nextLine();
  99.             } catch (Exception e){
  100.                 System.out.println("Error: " + e);
  101.                 continue;
  102.             }
  103.             if (backtrack(user)){
  104.                 bool = false;
  105.                 return 0;
  106.             }
  107.             System.out.print("Password: ");
  108.             try{
  109.                 pass = input.nextLine();
  110.             } catch (Exception e){
  111.                 System.out.println("Error: " + e);
  112.             }
  113.            
  114.             if (backtrack(pass)){
  115.                 bool = false;
  116.                 return 0;
  117.             }
  118.             else if (user.equals("admin") && pass.equals("admin")){
  119.                 System.out.println("Login Successfully");
  120.                 bool = false;
  121.                 return 10;
  122.             }
  123.             else {
  124.                 System.out.println("Invalid username or password");
  125.             }
  126.         }while (bool);
  127.         return 0;
  128.     }
  129.    
  130.     private int user(){
  131.         String x;
  132.        
  133.         boolean bool;
  134.         do {
  135.             bool = false;
  136.             System.out.println("-1 to back");
  137.             System.out.println("(1)Login\n(2)Register");
  138.             try{
  139.                 x = input.nextLine();
  140.             }
  141.             catch (Exception e){
  142.                 System.out.println("Invalid input, " + e);
  143.                 continue;
  144.             }
  145.            
  146.             if (x.equals("1")){
  147.                 return 3;
  148.             }
  149.             else if (x.equals("2")){
  150.                 return 4;
  151.             }
  152.             else if (x.equals("-1")){
  153.                 return 0;
  154.             }
  155.             else {
  156.                 System.out.println("Invalid input, please try again");
  157.                 bool = true;
  158.                 continue;
  159.             }
  160.         }while(bool);
  161.         return 0;
  162.     }
  163.    
  164.     private int userLogin(){
  165.         boolean bool = true;
  166.         String user, pass = null;
  167.         loadDat();
  168.         do{
  169.             System.out.println("-1 to back");
  170.             System.out.print("Username: ");
  171.             try {
  172.                 user = input.nextLine();
  173.             } catch (Exception e){
  174.                 System.out.println("Error: " + e);
  175.                 continue;
  176.             }
  177.             if (backtrack(user)){
  178.                 bool = false;
  179.                 return 2;
  180.             }
  181.             System.out.print("Password: ");
  182.             try{
  183.                 pass = input.nextLine();
  184.             } catch (Exception e){
  185.                 System.out.println("Error: " + e);
  186.             }
  187.             if (backtrack(pass)){
  188.                 bool = false;
  189.                 return 2;
  190.             }
  191.             else {
  192.                 for (int i = 0; i < this.username.size(); i++) {
  193.                     if (user.equals(this.username.get(i)) && pass.equals(this.password.get(i))){
  194.                         System.out.println("Login Successfully");
  195.                         System.out.println();
  196.                         bool = false;
  197.                         account = this.username.get(i);
  198.                         return 5;
  199.                     }
  200.                 }
  201.                 System.out.println("Invalid username or password");
  202.             }  
  203.         }while(bool);
  204.         return 0;
  205.     }
  206.    
  207.     private int userReg(){
  208.         String user, pass;
  209.         boolean bool = true;
  210.         boolean bool2 = false;
  211.         boolean taken;
  212.         loadDat();
  213.         System.out.println("-1 to back");
  214.         System.out.println("Register as");
  215.        
  216.         do{
  217.             taken = false;
  218.             System.out.print("Username: ");
  219.             user = input.nextLine();
  220.             if (backtrack(user)){
  221.                 return 2;
  222.             }
  223.            
  224.             for (int i = 0; i < this.username.size(); i++) {
  225.                 if (user.equals(this.username.get(i))){
  226.                     System.out.println("Username taken, please take different username");
  227.                     taken = true;
  228.                     continue;
  229.                 }
  230.             }
  231.            
  232.             if (taken){
  233.                 continue;
  234.             }
  235.            
  236.             else if(user.contains(" ")){
  237.                 System.out.println("Username or password cannot contain space");
  238.                 continue;
  239.             }
  240.            
  241.             else {
  242.                 do {
  243.                     bool2 = false;
  244.                     System.out.print("Password: ");
  245.                     pass = input.nextLine();
  246.                     if (backtrack(pass)){
  247.                         return 2;
  248.                     }
  249.                     else if (pass.contains(" ")){
  250.                         System.out.println("Username or password cannot contain space");
  251.                         bool2 = true;
  252.                         continue;
  253.                     }
  254.                     else {
  255.                         addDat(user, pass);
  256.                         System.out.println("Account created successfully");
  257.                         bool = false;
  258.                         return 2;
  259.                     }
  260.                 }while(bool2);
  261.             }
  262.         }while(bool);
  263.         return 0;
  264.     }
  265.    
  266.     private int userMenu(){
  267.         boolean bool = true;
  268.         String x = null;
  269.         System.out.println("Welcome back, " + account);
  270.         do{
  271.            
  272.             System.out.println("(1)Shop\n(2)Status\n(3)Log Out");
  273.             try {
  274.                 x = input.nextLine();
  275.             } catch (Exception e) {
  276.                 System.out.println("Invalid input, " + e);
  277.             }
  278.             if (x.equals("1")){
  279.                 bool = false;
  280.                 return 6;
  281.             }
  282.             else if (x.equals("2")){
  283.                 bool = false;
  284.                 return 7;
  285.             }
  286.             else if (x.equals("3")){
  287.                 bool = false;
  288.                 return 0;
  289.             }
  290.             else {
  291.                 System.out.println("Invalid input, please try again");
  292.             }
  293.         }while(bool);
  294.         return 0;
  295.     }
  296.    
  297.     private int userShop(){
  298.         boolean bool, bool2, bool3, checkOut;
  299.         int x, color, size = 0, amount;
  300.         String in;
  301.         String c, s, g, t;
  302.         do {
  303.             checkOut = false;
  304.             System.out.println("-1 to back, clear cart");
  305.             System.out.println("Men\tWomen\n(1)Top\t(3)Dress\n(2)Pant\t(4)Skirt\n(5)View cart\n(6)Checkout");
  306.             try {
  307.                 in = input.nextLine();
  308.                 x = Integer.parseInt(in);
  309.             }
  310.             catch(Exception e){
  311.                 System.out.println("Invalid input, " + e);
  312.                 continue;
  313.             }
  314.             if (x >= 1 && x <= 4){
  315.                 do{
  316.                     bool = true;
  317.                     System.out.println("-1 to back");
  318.                     System.out.println("Choose a color:");
  319.                     System.out.println("(1)White\n(2)Black\n(3)Red\n(4)Green\n(5)Blue");
  320.                     try {
  321.                         in = input.nextLine();
  322.                         color = Integer.parseInt(in);
  323.                     }
  324.                     catch (Exception e){
  325.                         System.out.println("Invalid input, " + e);
  326.                         continue;
  327.                     }
  328.                     if (color >= 1 && color <= 5){
  329.                         do {
  330.                             bool2 = true;
  331.                             System.out.println("-1 to back");
  332.                             System.out.println("Choose a size:");
  333.                             System.out.println("(1)S\n(2)M\n(3)L");
  334.                             try {
  335.                                 in = input.nextLine();
  336.                                 size = Integer.parseInt(in);
  337.                             }
  338.                             catch (Exception e){
  339.                                 System.out.println("Invalid input, " + e);
  340.                                 continue;
  341.                             }
  342.                             if (size >= 1 && size <= 3){
  343.                                 do {
  344.                                     bool3 = true;
  345.                                     System.out.println("-1 to back");
  346.                                     System.out.print("Amount: ");
  347.                                     try {
  348.                                         in = input.nextLine();
  349.                                         amount = Integer.parseInt(in);
  350.                                     }
  351.                                     catch (Exception e){
  352.                                         System.out.println("Invalid input, " + e);
  353.                                         continue;
  354.                                     }
  355.                                     if (amount < 1){
  356.                                         System.out.println("Amount cannot less than 1");
  357.                                         continue;
  358.                                     }
  359.                                     else if (backtrack(amount)){
  360.                                         bool3 = false;
  361.                                         break;
  362.                                     }
  363.                                     else {
  364.                                         g = gGet(x);
  365.                                         c = cGet(color);
  366.                                         s = sGet(size);
  367.                                         t = tGet(x);
  368.                                         addCart(t, c, s, amount);
  369.                                         System.out.printf("%s %s %s (%s) x %d added to cart\n\n", g, t, c, s, amount);
  370.                                         bool = false;
  371.                                         bool2 = false;
  372.                                         bool3 = false;
  373.                                     }
  374.                                 } while (bool3);
  375.                             }
  376.                             else if(backtrack(size)){
  377.                                 bool2 = false;
  378.                                 break;
  379.                             }
  380.                             else {
  381.                                 System.out.println("Invalid input, please try again");
  382.                             }
  383.                         }while(bool2);
  384.                     }
  385.                     else if (backtrack(color)){
  386.                         bool = false;
  387.                         break;
  388.                     }
  389.                     else {
  390.                         System.out.println("Invalid input, please try again");
  391.                     }
  392.                 }while(bool);
  393.             }
  394.             else if(x == 5){
  395.                 if (tempT.amount >= 1){
  396.                     System.out.printf("%s %s %s (%s) x %d\n", tempT.group, tempT.type, tempT.color, tempT.size, tempT.amount);
  397.                 }
  398.                 if (tempP.amount >= 1){
  399.                     System.out.printf("%s %s %s (%s) x %d\n", tempP.group, tempP.type, tempP.color, tempP.size, tempP.amount);
  400.                 }
  401.                 if (tempD.amount >= 1){
  402.                     System.out.printf("%s %s %s (%s) x %d\n", tempD.group, tempD.type, tempD.color, tempD.size, tempD.amount);
  403.                 }
  404.                 if (tempS.amount >= 1){
  405.                     System.out.printf("%s %s %s (%s) x %d\n", tempS.group, tempS.type, tempS.color, tempS.size, tempS.amount);
  406.                 }
  407.                 System.out.println();
  408.                 System.out.println("Press Enter to continue\n");
  409.                 input.nextLine();
  410.             }
  411.             else if(x == 6){
  412.                 addOrder(account);
  413.                 checkOut = true;
  414.                 loadOrder();
  415.                 System.out.println("Thanks\nYour order number is #" + userOrder.size() + "\nPlease come again!\n");
  416.                 return 5;
  417.             }
  418.             else if(backtrack(x)){
  419.                 tempT.amount = 0;
  420.                 tempP.amount = 0;
  421.                 tempD.amount = 0;
  422.                 tempS.amount = 0;
  423.                 return 5;
  424.             }
  425.             else {
  426.                 System.out.println("Invalid input, try again");
  427.             }
  428.         }while(!checkOut);
  429.         return 0;
  430.     }
  431.    
  432.     private int userStatus(){
  433.         loadOrder();
  434.         boolean order = false;
  435.        
  436.         for (int i = 0; i < this.userOrder.size(); i++) {
  437.             if (this.userOrder.get(i).equals(account)){
  438.                 System.out.println();
  439.                 order = true;
  440.                 System.out.println("Order #" + i);
  441.                 if(((Top)top.get(i)).amount > 0){
  442.                     System.out.printf("%s %s %s (%s) x %d\n", ((Top)top.get(i)).group, ((Top)top.get(i)).type, ((Top)top.get(i)).color, ((Top)top.get(i)).size, ((Top)top.get(i)).amount);
  443.                 }
  444.                 if(((Pant)pant.get(i)).amount > 0){
  445.                     System.out.printf("%s %s %s (%s) x %d\n", ((Pant)pant.get(i)).group, ((Pant)pant.get(i)).type, ((Pant)pant.get(i)).color, ((Pant)pant.get(i)).size, ((Pant)pant.get(i)).amount);
  446.                 }
  447.                 if(((Dress)dress.get(i)).amount > 0){
  448.                     System.out.printf("%s %s %s (%s) x %d\n", ((Dress)dress.get(i)).group, ((Dress)dress.get(i)).type, ((Dress)dress.get(i)).color, ((Dress)dress.get(i)).size, ((Dress)dress.get(i)).amount);
  449.                 }
  450.                 if(((Skirt)skirt.get(i)).amount > 0){
  451.                     System.out.printf("%s %s %s (%s) x %d\n", ((Skirt)skirt.get(i)).group, ((Skirt)skirt.get(i)).type, ((Skirt)skirt.get(i)).color, ((Skirt)skirt.get(i)).size, ((Skirt)skirt.get(i)).amount);
  452.                 }
  453.                 System.out.println("Order confirm: " + orderStatus.get(i));
  454.                 System.out.println("Shipping confirm: " + shipStatus.get(i));
  455.             }
  456.         }
  457.         if (!order){
  458.             System.out.println();
  459.             System.out.println("Empty, you did not order anything in the past");
  460.         }
  461.         System.out.println("\nPress Enter to continue");
  462.         input.nextLine();
  463.         return 5;
  464.     }
  465.    
  466.     private void loadDat(){
  467.         readWrite read = new readWrite();
  468.         read.openWrite("login.txt");
  469.         read.openRead("login.txt");
  470.         read.readDat();
  471.         username.clear();
  472.         password.clear();
  473.         for (int i = 0; i < read.user.size(); i++) {
  474.             this.username.add(read.user.get(i));
  475.             this.password.add(read.pass.get(i));
  476.         }
  477.         read.closeRead();
  478.     }
  479.    
  480.    
  481.     private void addDat(String user, String pass){
  482.         readWrite write = new readWrite();
  483.         write.openWrite("login.txt");
  484.         write.openRead("login.txt");
  485.         write.readDat();
  486.         write.closeRead();
  487.         write.user.add(user);
  488.         write.pass.add(pass);
  489.         write.openWrite("login.txt");
  490.         write.writeDat();
  491.         write.closeWrite();
  492.     }
  493.    
  494.     private void loadOrder(){
  495.         readWrite readOrder = new readWrite();
  496.         readOrder.openWrite("order.txt");
  497.         readOrder.openRead("order.txt");
  498.         readOrder.readStatus();
  499.         userOrder.clear();
  500.         orderStatus.clear();
  501.         shipStatus.clear();
  502.         top.clear();
  503.         pant.clear();
  504.         dress.clear();
  505.         skirt.clear();
  506.         for (int i = 0; i < readOrder.userOrder.size(); i++) {
  507.             this.userOrder.add(readOrder.userOrder.get(i));
  508.             this.orderStatus.add(readOrder.orderStatus.get(i));
  509.             this.shipStatus.add(readOrder.shipStatus.get(i));
  510.             this.top.add(readOrder.top.get(i));
  511.             this.pant.add(readOrder.pant.get(i));
  512.             this.dress.add(readOrder.dress.get(i));
  513.             this.skirt.add(readOrder.skirt.get(i));
  514.         }
  515.     }
  516.    
  517.     private void addOrder(String user){
  518.         readWrite write = new readWrite();
  519.         write.openWrite("order.txt");
  520.         write.openRead("order.txt");
  521.         write.readStatus();
  522.         write.closeRead();
  523.         write.userOrder.add(user);
  524.         write.orderStatus.add("Pending");
  525.         write.shipStatus.add("Pending");
  526.         write.top.add(tempT);
  527.         write.pant.add(tempP);
  528.         write.dress.add(tempD);
  529.         write.skirt.add(tempS);
  530.         write.openWrite("order.txt");
  531.         write.writeOrder();
  532.         write.closeWrite();
  533.     }
  534.    
  535.     private boolean backtrack(String back){
  536.         if (back.equals("-1")){
  537.             return true;
  538.         }
  539.         else {
  540.             return false;
  541.         }
  542.     }
  543.    
  544.     private boolean backtrack(int back){
  545.         if (back == -1){
  546.             return true;
  547.         }
  548.         else {
  549.             return false;
  550.         }
  551.     }
  552.    
  553.     private String gGet(int x){
  554.         if (x == 1 || x == 2){
  555.             return "Men";
  556.         }
  557.         else if (x == 3 || x == 4){
  558.             return "Women";
  559.         }
  560.         else {
  561.             return "Invalid";
  562.         }
  563.     }
  564.    
  565.     private String tGet(int x){
  566.         if (x == 1){
  567.             return "Top";
  568.         }
  569.         else if (x == 2){
  570.             return "Pant";
  571.         }
  572.         else if (x == 3){
  573.             return "Dress";
  574.         }
  575.         else if (x == 4){
  576.             return "Skirt";
  577.         }
  578.         else {
  579.             return "Invalid";
  580.         }
  581.     }
  582.    
  583.     private String cGet(int x){
  584.         if (x == 1){
  585.             return "White";
  586.         }
  587.         else if (x == 2){
  588.             return "Black";
  589.         }
  590.         else if (x == 3){
  591.             return "Red";
  592.         }
  593.         else if (x == 4){
  594.             return "Green";
  595.         }
  596.         else if (x == 5){
  597.             return "Blue";
  598.         }
  599.         else {
  600.             return "Invalid";
  601.         }
  602.     }
  603.    
  604.     private String sGet(int x){
  605.         if (x == 1){
  606.             return "S";
  607.         }
  608.         else if (x == 2){
  609.             return "M";
  610.         }
  611.         else if (x == 3){
  612.             return "L";
  613.         }
  614.         else {
  615.             return "Invalid";
  616.         }
  617.     }
  618.    
  619.     private void addCart(String t, String c, String s, int amount){
  620.         if (t.equals("Top")){
  621.             tempT.amount = amount;
  622.             tempT.color = c;
  623.             tempT.size = s;
  624.             tempT.group = "Men";
  625.         }
  626.         else if (t.equals("Pant")){
  627.             tempP.amount = amount;
  628.             tempP.color = c;
  629.             tempP.size = s;
  630.             tempP.group = "Men";
  631.         }
  632.         else if (t.equals("Dress")){
  633.             tempD.amount = amount;
  634.             tempD.color = c;
  635.             tempD.size = s;
  636.             tempD.group = "Women";
  637.         }
  638.         else if (t.equals("Skirt")){
  639.             tempS.amount = amount;
  640.             tempS.color = c;
  641.             tempS.size = s;
  642.             tempS.group = "Women";
  643.         }
  644.     }
  645. }
  646.  
  647. package assignment;
  648.  
  649. import java.io.File;
  650. import java.io.FileNotFoundException;
  651. import java.io.PrintWriter;
  652. import java.util.Scanner;
  653. import java.util.ArrayList;
  654.  
  655. public class readWrite {
  656.     private Scanner y;
  657.     protected ArrayList<String> user = new ArrayList<String>();
  658.     protected ArrayList<String> pass = new ArrayList<String>();
  659.     protected ArrayList<String> userOrder = new ArrayList<String>();
  660.     protected ArrayList<String> shipStatus = new ArrayList<String>();
  661.     protected ArrayList<String> orderStatus = new ArrayList<String>();
  662.     protected ArrayList<Top> top = new ArrayList<Top>();
  663.     protected ArrayList<Pant> pant = new ArrayList<Pant>();
  664.     protected ArrayList<Dress> dress = new ArrayList<Dress>();
  665.     protected ArrayList<Skirt> skirt = new ArrayList<Skirt>();
  666.     File file;
  667.     PrintWriter pw;
  668.    
  669.     protected void openWrite(String fileName){
  670.         try {
  671.             file = new File(fileName);
  672.             if(!file.exists()){
  673.                 file.createNewFile();
  674.             }
  675.         }
  676.         catch (Exception e) {
  677.             System.out.println("Failed to create/open file " + e);
  678.         }
  679.     }
  680.    
  681.     protected void writeDat(){
  682.         try {
  683.             pw = new PrintWriter(file);
  684.         }
  685.         catch (FileNotFoundException e) {
  686.             System.out.println("Failed to write file " + e);
  687.         }
  688.         for (int i = 0; i < this.user.size(); i++) {
  689.             pw.println(this.user.get(i));
  690.             pw.println(this.pass.get(i));
  691.         }
  692.     }
  693.    
  694.     protected void writeOrder(){
  695.         try{
  696.             pw = new PrintWriter(file);
  697.         }
  698.         catch (Exception e){
  699.             System.out.println("Failed to write file " + e);
  700.         }
  701.         for (int i = 0; i < this.userOrder.size(); i++) {
  702.             pw.println(this.userOrder.get(i));
  703.             pw.println(this.orderStatus.get(i));
  704.             pw.println(this.shipStatus.get(i));
  705.             pw.println(((Top)top.get(i)).amount + " " + ((Top)top.get(i)).color + " " + ((Top)top.get(i)).size + " " + ((Top)top.get(i)).group);
  706.             pw.println(((Pant)pant.get(i)).amount + " " + ((Pant)pant.get(i)).color + " " + ((Pant)pant.get(i)).size + " " + ((Pant)pant.get(i)).group);
  707.             pw.println(((Dress)dress.get(i)).amount + " " + ((Dress)dress.get(i)).color + " " + ((Dress)dress.get(i)).size + " " + ((Dress)dress.get(i)).group);
  708.             pw.println(((Skirt)skirt.get(i)).amount + " " + ((Skirt)skirt.get(i)).color + " " + ((Skirt)skirt.get(i)).size + " " + ((Skirt)skirt.get(i)).group);
  709.         }
  710.     }
  711.    
  712.     protected void closeWrite(){
  713.         pw.close();
  714.     }
  715.    
  716.     protected void openRead(String fileName){
  717.         try {
  718.             y = new Scanner(new File(fileName));
  719.         }
  720.         catch (Exception e) {
  721.             System.out.println(e);
  722.         }
  723.     }
  724.    
  725.     protected void readDat(){
  726.         while(y.hasNext()){
  727.             this.user.add(y.next());
  728.             this.pass.add(y.next());
  729.         }
  730.     }
  731.    
  732.     protected void readStatus(){
  733.         Top t = new Top();
  734.         Pant p = new Pant();
  735.         Dress d = new Dress();
  736.         Skirt s = new Skirt();
  737.         while(y.hasNext()){
  738.             this.userOrder.add(y.next());
  739.             this.orderStatus.add(y.next());
  740.             this.shipStatus.add(y.next());
  741.             t.amount = Integer.parseInt(y.next());
  742.             t.color = y.next();
  743.             t.size = y.next();
  744.             t.group = y.next();
  745.             this.top.add(t);
  746.             p.amount = Integer.parseInt(y.next());
  747.             p.color = y.next();
  748.             p.size = y.next();
  749.             p.group = y.next();
  750.             this.pant.add(p);
  751.             d.amount = Integer.parseInt(y.next());
  752.             d.color = y.next();
  753.             d.size = y.next();
  754.             d.group = y.next();
  755.             this.dress.add(d);
  756.             s.amount = Integer.parseInt(y.next());
  757.             s.color = y.next();
  758.             s.size = y.next();
  759.             s.group = y.next();
  760.             this.skirt.add(s);
  761.         }
  762.     }
  763.    
  764.     protected void display(){
  765.         for (int i = 0; i < this.user.size(); i++) {
  766.             System.out.println(this.user.get(i));
  767.             System.out.println(this.pass.get(i));
  768.         }
  769.     }
  770.    
  771.     protected void closeRead(){
  772.         y.close();
  773.     }
  774. }
  775.  
  776. package assignment;
  777.  
  778. public class Clothing {
  779.     int amount;
  780.     String color, size, group, type;
  781. }
Advertisement
Add Comment
Please, Sign In to add comment