weiqian1020

20/6/17

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