1 4 package demo.tasklist.service; 5 6 import java.util.ArrayList ; 7 8 12 public class DataKeeper { 13 14 private ArrayList userList; 15 16 public DataKeeper() { 17 userList = new ArrayList (); 18 } 19 20 public void addListItem(String newListItem) { 21 if(newListItem != null){ 22 userList.add(newListItem); 23 } 24 } 25 26 public void deleteListItems(String [] itemsForDelete) { 27 if(itemsForDelete != null) { 28 for (int i=0; i<itemsForDelete.length; i++) { 29 userList.remove(itemsForDelete[i]); 30 } 31 } 32 } 33 34 public int getListSize() { 35 if (userList == null) { 36 return 0; 37 } 38 return userList.size(); 39 } 40 41 public String getListItem(int index) { 42 return (String )userList.get(index); 43 } 44 45 public ArrayList getList() { 46 return userList; 47 } 48 49 } | Popular Tags |