Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. import java.util.*;
  2. import java.util.LinkedList;
  3. import java.util.Scanner;
  4. import java.util.concurrent.TimeUnit;
  5.  
  6.  
  7. public class Products {
  8.  
  9. String name;
  10. double price;
  11. List<String> list
  12. List<Double> price
  13.  
  14. public Products(String name, double price) {
  15. this.name = name;
  16. this.price = price;
  17. }
  18.  
  19. public void gowno(){
  20. System.out.println("lol");
  21. }
  22.  
  23. static public void productsList() throws InterruptedException {
  24.  
  25.  
  26. int choice, count;
  27.  
  28. list = new LinkedList<String>();
  29. price = new LinkedList<Double>();
  30. //
  31. // List<String> checkoutName = new LinkedList<String>();
  32. // List<Double> checkoutPrice = new LinkedList<Double>();
  33.  
  34. System.out.println("Available products: \n");
  35.  
  36. Products butter = new Products ("Butter", 3.00);
  37. list.add(butter.name);
  38. price.add(butter.price);
  39.  
  40. Products milk = new Products ("Milk", 2.20);
  41. list.add(milk.name);
  42. price.add(milk.price);
  43.  
  44. Products gouda = new Products ("Gouda cheese", 8.50);
  45. list.add(gouda.name);
  46. price.add(gouda.price);
  47.  
  48. Products bread = new Products ("Bread", 2.00);
  49. list.add(bread.name);
  50. price.add(bread.price);
  51.  
  52. Products roll = new Products ("Roll", 0.30);
  53. list.add(roll.name);
  54. price.add(roll.price);
  55.  
  56. Products eggplant = new Products("Eggplant", 6.00);
  57. list.add(eggplant.name);
  58. price.add(eggplant.price);
  59.  
  60.  
  61. for (int i = 0 ; i < list.size(); i++) {
  62. System.out.print(i+1+") " + list.get(i) +" "+ price.get(i));
  63. System.out.println();
  64. }
  65.  
  66.  
  67. System.out.println("Add to basket nr: ");
  68. Scanner scan = new Scanner(System.in);
  69. choice = scan.nextInt();
  70.  
  71.  
  72.  
  73. TimeUnit.SECONDS.sleep(1);
  74. // System.out.println(gowno.nazwa + " " + gowno.suma);
  75.  
  76.  
  77.  
  78. switch(choice) {
  79. case 1: {
  80. System.out.println("\nGive the quantity: ");
  81. count = scan.nextInt();
  82. System.out.println(list.get(choice-1) +" "+ count*price.get(choice-1));
  83.  
  84. // checkoutName.add(list.get(choice-1));
  85. // checkoutPrice.add(count*price.get(choice-1));
  86. // System.out.println(checkoutName + " " + checkoutPrice);
  87. break;
  88. }
  89.  
  90. case 2: {
  91. break;
  92. }
  93.  
  94. case 3: {
  95. break;
  96. }
  97.  
  98. case 4: {
  99. break;
  100. }
  101.  
  102. case 5: {
  103. break;
  104. }
  105.  
  106. case 6: {
  107. break;
  108. }
  109.  
  110. case 7: {
  111. break;
  112. }
  113.  
  114.  
  115. }
  116.  
  117.  
  118. }
  119.  
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement