Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package arraylists;
- import java.util.Scanner;
- import java.util.ArrayList;
- import java.util.*;
- //Kendall Clancy
- //That Irelia main hehe xd
- //Summoner name: AAC Wrath
- public class ArrayLists
- {
- public static void main(String[] args)
- {
- ArrayLists bob = new ArrayLists();
- ArrayList<String> places = new ArrayList<String>();
- System.out.println("This is a program that allows you to manipulate an Arraylist from the user's inputs");
- bob.One(places);
- }
- protected void One(ArrayList places)
- {
- ArrayLists bob = new ArrayLists();
- Scanner AnnieBot = new Scanner(System.in);
- System.out.println("Entering the following number will transfer you to a different method");
- System.out.println("1 for add, 2 for Remove, 3 for Set, 4 for Sort, 5 for Print, and 6 for Delete");
- int Input = AnnieBot.nextInt();
- if (Input == 1)
- {
- bob.Add(places);
- }
- if (Input == 2)
- {
- bob.Remove(places);
- }
- if (Input == 3)
- {
- bob.Set(places);
- }
- if (Input == 4)
- {
- bob.Sort(places);
- }
- if (Input == 5)
- {
- bob.Print(places);
- }
- if (Input == 6)
- {
- bob.Delete(places);
- }
- else
- {
- System.out.println("Please enter a number 1-5");
- bob.One(places);
- }
- } //end one
- protected void Add(ArrayList places)
- {
- ArrayLists bob = new ArrayLists();
- Scanner AnnieBot = new Scanner(System.in);
- System.out.println("In what position would you like to add it?");
- int WhatPosition = AnnieBot.nextInt();
- System.out.println("What would you like to add to it?");
- String WhatAdd = AnnieBot.nextLine();
- places.add(WhatPosition,WhatAdd);
- }
- protected void Remove(ArrayList places)
- {
- ArrayLists bob = new ArrayLists();
- Scanner AnnieBot = new Scanner(System.in);
- System.out.println("What position in the list do you want to remove?");
- int RemoveNumber = AnnieBot.nextInt();
- places.remove(RemoveNumber);
- bob.One(places);
- }
- protected void Set(ArrayList places)
- {
- ArrayLists bob = new ArrayLists();
- Scanner AnnieBot = new Scanner(System.in);
- System.out.println("What position do you want to change?");
- int WhatPosition = AnnieBot.nextInt();
- System.out.println("What do you want to change it to?");
- String WhatValue = AnnieBot.nextLine();
- places.set(WhatPosition,WhatValue);
- bob.One(places);
- }
- protected void Sort(ArrayList places)
- {
- ArrayLists bob = new ArrayLists();
- Scanner AnnieBot = new Scanner(System.in);
- System.out.println("How do you want to sort it? 1 for Ascending, 2 for Descending");
- int AorD = AnnieBot.nextInt();
- if (AorD == 1)
- {
- Collections.sort(places);
- }
- if(AorD == 2)
- {
- Collections.sort(places);
- Collections.reverse(places);
- }
- bob.One(places);
- }
- protected void Print(ArrayList places)
- {
- ArrayLists bob = new ArrayLists();
- Scanner AnnieBot = new Scanner(System.in);
- System.out.println(places);
- bob.One(places);
- }
- protected void Delete(ArrayList places)
- {
- ArrayLists bob = new ArrayLists();
- Scanner AnnieBot = new Scanner(System.in);
- Collections.clear(places); //I don't know what the keyword for clearing it is yet
- bob.One(places);
- }
- protected void WriteToFile()
- {
- //insert stuff
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement