1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import java.util.ArrayList;
- import java.util.List;
- public class Entry
- {
- String phoneNumber;
- List<String> entryArray = new ArrayList <String>();
-
- public Entry(String phoneNumber){
- entryArray.add(0,phoneNumber);
- }
-
- public String getPhoneNumber(){
- StringBuilder phoneNumber = new StringBuilder();
- if(entryArray.size()>1){
- for(int i = 0; i < entryArray.size()-1; i++){
- phoneNumber.append(entryArray.get(i) + ", ");
- }
- }
- phoneNumber.append(entryArray.get(entryArray.size()-1));
- return phoneNumber.toString();
- }
-
- public void addPhoneNumber(String phoneNumber){
- entryArray.add(phoneNumber);
- }
-
- public boolean entryArrayContainsNumber(String phonenumber){
- boolean containsNumber = false;
- if(entryArray.contains(phonenumber)){
- containsNumber = true;
- }
- return containsNumber;
- }
-
- public int getNumberOfRecords(){
- return entryArray.size();
- }
-
- public void removePhoneNumber(String phoneNumber){
- for(String number:entryArray){
- if(phoneNumber.equals(number)){
- entryArray.remove(number);
- break;
- }
- }
- }
- }
|