Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. package arraylists;
  2. import java.util.Scanner;
  3. import java.util.ArrayList;
  4. import java.util.*;
  5. //Kendall Clancy
  6. //That Irelia main hehe xd
  7. //Summoner name: AAC Wrath
  8. public class ArrayLists
  9. {
  10.  
  11.  
  12. public static void main(String[] args)
  13. {
  14. ArrayLists bob = new ArrayLists();
  15. ArrayList<String> places = new ArrayList<String>();
  16. System.out.println("This is a program that allows you to manipulate an Arraylist from the user's inputs");
  17. bob.One(places);
  18. }
  19.  
  20. protected void One(ArrayList places)
  21. {
  22. ArrayLists bob = new ArrayLists();
  23. Scanner AnnieBot = new Scanner(System.in);
  24. System.out.println("Entering the following number will transfer you to a different method");
  25. System.out.println("1 for add, 2 for Remove, 3 for Set, 4 for Sort, 5 for Print, and 6 for Delete");
  26. int Input = AnnieBot.nextInt();
  27. if (Input == 1)
  28. {
  29. bob.Add(places);
  30. }
  31. if (Input == 2)
  32. {
  33. bob.Remove(places);
  34. }
  35. if (Input == 3)
  36. {
  37. bob.Set(places);
  38. }
  39. if (Input == 4)
  40. {
  41. bob.Sort(places);
  42. }
  43. if (Input == 5)
  44. {
  45. bob.Print(places);
  46. }
  47. if (Input == 6)
  48. {
  49. bob.Delete(places);
  50. }
  51. else
  52. {
  53. System.out.println("Please enter a number 1-5");
  54. bob.One(places);
  55. }
  56. } //end one
  57.  
  58. protected void Add(ArrayList places)
  59. {
  60. ArrayLists bob = new ArrayLists();
  61. Scanner AnnieBot = new Scanner(System.in);
  62. System.out.println("In what position would you like to add it?");
  63. int WhatPosition = AnnieBot.nextInt();
  64. System.out.println("What would you like to add to it?");
  65. String WhatAdd = AnnieBot.nextLine();
  66.  
  67.  
  68. places.add(WhatPosition,WhatAdd);
  69.  
  70. }
  71.  
  72. protected void Remove(ArrayList places)
  73. {
  74. ArrayLists bob = new ArrayLists();
  75. Scanner AnnieBot = new Scanner(System.in);
  76. System.out.println("What position in the list do you want to remove?");
  77. int RemoveNumber = AnnieBot.nextInt();
  78. places.remove(RemoveNumber);
  79. bob.One(places);
  80. }
  81.  
  82. protected void Set(ArrayList places)
  83. {
  84. ArrayLists bob = new ArrayLists();
  85. Scanner AnnieBot = new Scanner(System.in);
  86. System.out.println("What position do you want to change?");
  87. int WhatPosition = AnnieBot.nextInt();
  88. System.out.println("What do you want to change it to?");
  89. String WhatValue = AnnieBot.nextLine();
  90. places.set(WhatPosition,WhatValue);
  91. bob.One(places);
  92. }
  93.  
  94. protected void Sort(ArrayList places)
  95. {
  96. ArrayLists bob = new ArrayLists();
  97. Scanner AnnieBot = new Scanner(System.in);
  98. System.out.println("How do you want to sort it? 1 for Ascending, 2 for Descending");
  99. int AorD = AnnieBot.nextInt();
  100. if (AorD == 1)
  101. {
  102. Collections.sort(places);
  103. }
  104.  
  105. if(AorD == 2)
  106. {
  107. Collections.sort(places);
  108. Collections.reverse(places);
  109. }
  110. bob.One(places);
  111. }
  112.  
  113. protected void Print(ArrayList places)
  114. {
  115. ArrayLists bob = new ArrayLists();
  116. Scanner AnnieBot = new Scanner(System.in);
  117. System.out.println(places);
  118. bob.One(places);
  119. }
  120.  
  121. protected void Delete(ArrayList places)
  122. {
  123. ArrayLists bob = new ArrayLists();
  124. Scanner AnnieBot = new Scanner(System.in);
  125. Collections.clear(places); //I don't know what the keyword for clearing it is yet
  126.  
  127. bob.One(places);
  128. }
  129.  
  130. protected void WriteToFile()
  131. {
  132. //insert stuff
  133. }
  134.  
  135.  
  136.  
  137.  
  138.  
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement