Advertisement
wxns

java_code

Sep 6th, 2017
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.93 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class program {
  4.  
  5.     public static class topClothing {
  6.  
  7.         private String[] sleeveLength = {"None", "Cap sleeves", "Short sleeves", "3/4 length sleeves", "Long sleeves", "Long sleeves with holes", "shirt sleeve length"};
  8.  
  9.         private String primaryColor;
  10.         private String secondaryColor;
  11.  
  12.         private String[] mannerWorn = {"Tucked over bottom", "Tucked under bottom", "Worn around waist"}; // 3rd option only for long sleeves
  13.  
  14.         public int maxquantityPockets;
  15.  
  16.         private String[][] pockets = new String[maxquantityPockets][2]; // second array value for properties
  17.  
  18.         public int getMaxquantityPockets() {
  19.             return maxquantityPockets;
  20.         }
  21.  
  22.         public int setMaxquantityPockets(int z) {
  23.             this.maxquantityPockets = z;
  24.             return z;
  25.         }
  26.  
  27.         public int pocketNumber(int userQu) {
  28.  
  29.         //    do {
  30.                 System.out.print("Please select the number of pockets you want to work with: ");
  31.                 Scanner qu = new Scanner(System.in);
  32.                 userQu = qu.nextInt();
  33.  
  34.                 if (userQu > 7 || userQu < 1) {
  35.                     System.out.println("Sorry, that is not a valid number of pockets. ");
  36.  
  37.                 } else {
  38.                     System.out.println("You have chosen " + userQu + " pockets to work with. ");
  39.                     return userQu;
  40.                 //    break;
  41.                 } // once this complete, values erased.
  42.         //    } while (repeat == 1);
  43.  
  44.             return userQu;
  45.         }
  46.         private void showPockets(String[][] pockets) {
  47.             int x;
  48.             for (x = 0; x < pockets.length; x++) {
  49.                 pockets[x][0] = ("Pocket " + (x + 1));
  50.                 System.out.println(pockets[x][0]);
  51.             }
  52.         }
  53.  
  54.             // get user input and validate it
  55.             // if outside of maximum pocket range, reject input
  56.             // user access to individual pockets and their individual properties
  57.  
  58.  
  59. /*
  60.                 for (x = 0; x < quantityPockets.length; x++) {
  61.                     if (userQuant == quantf) {
  62.                         break;
  63.                     }
  64.                 }
  65.  
  66.                 System.out.println("Please enter the pocket number you want to work with: ");
  67.  
  68.                 for (x = 0; x < quantf; x++) {
  69.                     System.out.println(x);
  70.                 }
  71. */
  72.  
  73. //        public int managePocketsQuantity.getQuantf
  74.  
  75.         private void managePockets(String[][] a) { // get value from outside method and set within method?
  76.             int repeat = 0;
  77.             int x;
  78.             int y;
  79.             for (x = 0; x < a.length; x++) {
  80.                 a[x][0] = ("Pocket " + (x+1));
  81.                 System.out.println(a[x][0]);
  82.             }
  83.             do {
  84.                 System.out.print("Please enter the pocket you want to work with: ");
  85.                 Scanner pocket = new Scanner(System.in);
  86.                 String userPocket = pocket.nextLine();
  87.  
  88.                 for (x = 0; x < a.length; x++) {
  89.                     if (userPocket.equals(a[x][0])) {
  90.                         break;
  91.                     }
  92.                 }
  93.                 if (x == a.length) {
  94.                     System.out.println("Sorry, we cannot work with that pocket."); // code never skips this
  95.                     x = 0;
  96.                     repeat = 1;
  97.                 } else {
  98.                     System.out.println("You have chosen to work with " + x + ". " + a[x][0]);
  99.                 }
  100.                 System.out.println("What properties would you like to have for this pocket?");
  101.                 Scanner property = new Scanner(System.in);
  102.                 String userProperty = property.nextLine();
  103.                 a[x][1] = userProperty;
  104.  
  105.                 System.out.println(a[x][0] + " has the following properties: " + a[x][1]);
  106.                 repeat = 0;
  107.             } while (repeat == 1);
  108.         }
  109.         //    int repeat2 = 0;
  110.         //    int y;
  111.  
  112.         private boolean hood;
  113.         private boolean zipUp;
  114.  
  115.         private void topPrint(){
  116.             String[] printLocations = {"Chest", "Back", "Sleeves"}; // 3rd option can't be applied with sleeveless
  117.             System.out.print("What sort of print would you like? ");
  118.  
  119.         }
  120.  
  121.         int quantity;
  122.  
  123.     }
  124.  
  125.     static int[] intInputVal(int[] userIntArray) {
  126.  
  127.         int repeat = 0;
  128.         int x;
  129.         do {
  130.  
  131.            System.out.println("Here is a list of the elements contained within your array: ");
  132.  
  133.            for (x = 0; x < userIntArray.length; x++) {
  134.                System.out.println(x + ". " + userIntArray[x]);
  135.            }
  136.  
  137.            Scanner intInput = new Scanner(System.in);
  138.            int userIntInput = intInput.nextInt();
  139.  
  140.            for (x = 0; x < userIntArray.length; x++) {
  141.                if (userIntInput == userIntArray[x] || userIntInput == x){
  142.                    break;
  143.                }
  144.            }
  145.  
  146.            if (x == userIntArray.length) {
  147.                System.out.println("Sorry, that was not a valid menu option");
  148.                x = 0;
  149.                repeat = 1;
  150.            } else {
  151.                System.out.println("You have chosen " + x + ". " + userIntArray[x]);
  152.                break;
  153.            }
  154.  
  155. //           for (int t: userArray) {
  156. //               System.out.println(x + ". " + t);
  157. //           }
  158.  
  159.         } while (repeat == 1);
  160.         return userIntArray;
  161.     }
  162.  
  163.     static String[] strInputVal(String[] userStrArray) {
  164.  
  165.         int repeat = 0;
  166.         int x;
  167.         do {
  168.  
  169.             System.out.println("Please select the " + userStrArray[userStrArray.length - 1] + " of your garment: ");
  170.  
  171.             for (x = 0; x < userStrArray.length - 1; x++) {
  172.                 System.out.println(userStrArray[x]);
  173.             }
  174.  
  175.             Scanner strInput = new Scanner(System.in);
  176.             String userStrInput = strInput.nextLine();
  177.  
  178.             for (x = 0; x < userStrArray.length - 1; x++) {
  179.                 if (userStrInput.equals(userStrArray[x])){ // cannot use == comparators as comparing string values!
  180.                     break;
  181.                 }
  182.             }
  183.  
  184.             if (x == userStrArray.length - 1) {
  185.                 System.out.println("Sorry, that was not a valid menu option");
  186.                 x = 0;
  187.                 repeat = 1;
  188.             } else {
  189.                 System.out.println("You have chosen " + userStrArray[x]);
  190.                 break;
  191.             }
  192.  
  193.         } while (repeat == 1);
  194.         return userStrArray;
  195.     }
  196.  
  197.     public static void main(String[] args){
  198.  
  199.         System.out.println("Hello World!");
  200.         int[] array = {33,34,35,36};
  201.         intInputVal(array);
  202.         topClothing shirt = new topClothing();
  203.         strInputVal(shirt.sleeveLength);
  204.         shirt.pocketNumber(shirt.maxquantityPockets);
  205.         shirt.showPockets(shirt.pockets);
  206.         shirt.managePockets(shirt.pockets);
  207.     }
  208.  
  209.  
  210.  
  211. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement