Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.LinkedList;
- public class PhoneBook {
- private int index;
- private int numberOfEntries;
- private LinkedList<Entry> book = new LinkedList<Entry>();
- public PhoneBook(int maxSize){
- }
- final boolean addNewEntry(TelephoneNumber t, Person p, Address a){
- book.add(index, new Entry(t, p, a));
- return true;
- }
- final int getIndex(){
- return index;
- }
- final boolean removeMarkedEntry(){
- if (book.isEmpty()== true){
- return false;
- }else{
- //getMarkedEntry()
- book.remove(getMarkedEntry());
- return true;
- }
- }
- final int countEntries(){
- return book.size();
- }
- public Entry getFirstEntry(){
- if(book.size() > 0){
- return book.get(0);
- }
- return null;
- }
- // final Entry getFirstEntry(){
- // if (book.isEmpty()){
- // return null;
- // }else
- // return book.getLast();
- // }
- final Entry getLastEntry(){
- if (book.isEmpty()){
- return null;
- }else
- return book.getFirst();
- }
- final Entry getMarkedEntry(){
- if (book.isEmpty()== true){
- return null;
- }else
- return book.get(index);
- }
- final void markNextEntry(){
- index = index + 1;
- }
- final void markPreviousEntry(){
- if (book.isEmpty()== false && book.getFirst()!=book.get(index))
- book.get(index-1);
- }
- public final String toString(){
- return book.toString();
- }
- }
Add Comment
Please, Sign In to add comment