Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main1 {
- public static void main(String[] args){
- CustomArrayList shoppingList = new CustomArrayList();
- Scanner scan = new Scanner(System.in);
- while (true){
- System.out.println();
- System.out.println("For Add choose 1, for Remove choose 2, for End choose 3");
- int choice = scan.nextInt();
- if(choice == 1){
- System.out.println("The element you want to add: ");
- String n = scan.next();
- if(shoppingList.contains(n) == false){
- shoppingList.add(n);
- System.out.println();
- System.out.println("Now your shopping list contains: ");
- for (int i = 0; i < shoppingList.getLength(); i++) {
- System.out.println(shoppingList.elementAt(i));
- }
- continue;
- }
- }else if(choice == 2){
- System.out.println("The element you want to remove: ");
- String n = scan.next();
- if(shoppingList.contains(n) == true){
- shoppingList.remove(n);
- System.out.println();
- System.out.println("Now your shopping list contains: ");
- for (int i = 0; i < shoppingList.getLength(); i++) {
- System.out.println(shoppingList.elementAt(i));
- }
- continue;
- }
- }else if(choice == 3){
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement