Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement a Java application allowing users to manage their Contact objects. You

ID: 3554055 • Letter: I

Question

Implement a Java application allowing users to manage their Contact objects. Your application should provide the users with the following options: (main menu)

1.       Add a new contact

2.       Search for a contact by name, email, or phone number (10 points bonus for wildcard [*] search) [edit option should be included in here too]

3.       Edit a contact

4.       Exit

Make sure to apply paging so the users can view a set of contacts per screen

You are free to design sub-menus for each option.

The Contact class is defined in Contact.java



public class Contact {

//constructors

public Contact(String fName, String emailOrPhone){

this.fName = fName;

if(isEmail(emailOrPhone)){ //check if it is an email

this.email = emailOrPhone;

}else {

this.primaryPhone = emailOrPhone;

}

}


public Contact(String fName, String lName, String emailOrPhone){

this.fName = fName;

this.lName = lName;

if(isEmail(emailOrPhone)){ //check if it is an email

this.email = emailOrPhone;

}else {

this.primaryPhone = emailOrPhone;

}

}

public Contact(String fName, String lName, String phone, String email){

this.fName = fName;

this.lName = lName;

this.email = email;

this.primaryPhone = phone;

}

//setter

public void setMobilePhone(String phone){

this.mobilePhone = phone;

}

public void setAddress(String address){

this.address = address;

}

public void setAlias(String alias){

this.alias = alias;

}


////////////////COMPLETE THEM

//helper methods

private boolean isEmail(String data){

if (....) // finish this code

return true;

return false; //it's not an email

}

public String toString(){//display the Contact as a string

}

  

// need to be able to compare/search for matching

  

//Put in appropriate getters

//attributes

private String fName, lName, title, alias,

primaryPhone, mobilePhone, email,

address; //address should be represented by an independent class


}

Explanation / Answer

import javax.swing.*;


public class addressbook {


public static void main(String []args){


}




private static double term;


private static String[] Name;


private static String[] Address;


private static int[] Telephone;


private static String[] Email;


private static int Entry=0;


private static double Add;


private static double View;


private static double Delete;





public static double getTerm(){




double AddEntry=0;


double DeleteEntry=0;


double ViewEntry=0;


double UpdateEntry=0;


double exit=0;


Name=new String[20];


Address=new String[20];


Telephone=new int[20];


Email=new String[20];



final int MAX_SIZE=5;


int[] arrOptions = new int[20];




for(int i=5;term<5;i=5){


term = Double.parseDouble(JOptionPane.showInputDialog( "Please, Select Transaction [1]Add Entry [2]Delete Entry [3]View All Entries [4]Update Entry [5]Exit", "Address Book"));


if(term==1){


AddEntry=addressbook.getEntry();


}


if(term==2){


DeleteEntry=addressbook.getDelete();


}


if(term==3){


ViewEntry=addressbook.getView();


}


if(term==4){


UpdateEntry=addressbook.getEntry();


addressbook.getView();


}


if(term==5){


exit=addressbook.getExit();


}


}


return term;

}


public static double getEntry(){


Entry = (int) Double.parseDouble(JOptionPane.showInputDialog("Enter the entry no. Select from 1-10: "))-1;




Name[Entry] = JOptionPane.showInputDialog(null, "Enter your Name:",JOptionPane.INFORMATION_MESSAGE);


Address[Entry] = JOptionPane.showInputDialog(null, "Enter your Address:",JOptionPane.INFORMATION_MESSAGE);


Telephone[Entry] = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter your Telephone No. :",JOptionPane.INFORMATION_MESSAGE));


Email[Entry] = JOptionPane.showInputDialog(null, "Enter your Email Address:",JOptionPane.INFORMATION_MESSAGE);



return term;


}




public static double getDelete(){


try{


Entry = (int) Double.parseDouble(JOptionPane.showInputDialog("En ter the entry you want to delete:"));


if(Entry<11&&Entry>0){




Name[Entry-1]="";


Address[Entry-1]="";


Telephone[Entry-1]=0;


Email[Entry-1]="";



JOptionPane.showMessageDialog(null,"Entry deleted!");


}


else{


JOptionPane.showMessageDialog(null, "Invalid Input");


}


}


catch(Exception e){


JOptionPane.showMessageDialog(null, "Please try again.","Error",JOptionPane.ERROR_MESSAGE);


System.exit(0);


}


return Delete;


}


public static double getView(){

try{


for(Entry=0;9>Entry;Entry=Entry+1){


JOptionPane.showMessageDialog(null, "Name: "+Name[Entry]+" Address: "+Address[Entry]+" Telephone #: "+Telephone[Entry]+" Email Address: "+Email[Entry]," ",JOptionPane.PLAIN_MESSAGE);


}




return View;

}


catch(Exception e){


JOptionPane.showMessageDialog(null, "Please try again.","Error",JOptionPane.ERROR_MESSAGE);


System.exit(0);


}


return View;


}


public static double getExit() {


double exit=0;


JOptionPane.showMessageDialog(null, "Exit");


System.exit(0);


return exit;

}

}


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote